Adding support for .NET 8.0 LTS, renaming private fields to start with underscore
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Newtonsoft.Json
|
||||
/// <summary>
|
||||
/// Common JSON serializer settings.
|
||||
/// </summary>
|
||||
private static readonly JsonSerializerSettings jsonSerializerSettings = new()
|
||||
private static readonly JsonSerializerSettings _jsonSerializerSettings = new()
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
Culture = CultureInfo.InvariantCulture
|
||||
@@ -32,7 +32,7 @@ namespace Newtonsoft.Json
|
||||
public static void DeserializeJson<T>(this T target, string json)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(json))
|
||||
JsonConvert.PopulateObject(json, target, jsonSerializerSettings);
|
||||
JsonConvert.PopulateObject(json, target, _jsonSerializerSettings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json
|
||||
/// <param name="json">The JSON string to read the values from.</param>
|
||||
/// <returns>A new instance of <typeparamref name="T"/> with the deserialized values.</returns>
|
||||
public static T DeserializeJson<T>(this string json)
|
||||
=> JsonConvert.DeserializeObject<T>(json, jsonSerializerSettings);
|
||||
=> JsonConvert.DeserializeObject<T>(json, _jsonSerializerSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes a JSON string into a new instance or using the fallback value.
|
||||
@@ -55,7 +55,7 @@ namespace Newtonsoft.Json
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(json, jsonSerializerSettings);
|
||||
return JsonConvert.DeserializeObject<T>(json, _jsonSerializerSettings);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -83,7 +83,7 @@ namespace Newtonsoft.Json
|
||||
jw.QuoteChar = '\'';
|
||||
|
||||
jw.Formatting = indented ? Formatting.Indented : Formatting.None;
|
||||
var serializer = useCamelCase ? JsonSerializer.Create(jsonSerializerSettings) : JsonSerializer.CreateDefault();
|
||||
var serializer = useCamelCase ? JsonSerializer.Create(_jsonSerializerSettings) : JsonSerializer.CreateDefault();
|
||||
|
||||
serializer.Error += (s, a) =>
|
||||
{
|
||||
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json
|
||||
if (obj == null)
|
||||
return null;
|
||||
|
||||
var serializer = JsonSerializer.Create(jsonSerializerSettings);
|
||||
var serializer = JsonSerializer.Create(_jsonSerializerSettings);
|
||||
return JObject.FromObject(obj, serializer);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Newtonsoft.Json
|
||||
if (array == null)
|
||||
return null;
|
||||
|
||||
var serializer = JsonSerializer.Create(jsonSerializerSettings);
|
||||
var serializer = JsonSerializer.Create(_jsonSerializerSettings);
|
||||
return JArray.FromObject(array, serializer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user