diff --git a/AMWD.Common/Extensions/JsonExtensions.cs b/AMWD.Common/Extensions/JsonExtensions.cs index 80fcc8e..7694833 100644 --- a/AMWD.Common/Extensions/JsonExtensions.cs +++ b/AMWD.Common/Extensions/JsonExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Globalization; using System.IO; using System.Text; using Newtonsoft.Json.Linq; @@ -19,7 +20,8 @@ namespace Newtonsoft.Json /// private static readonly JsonSerializerSettings jsonSerializerSettings = new() { - ContractResolver = new CamelCasePropertyNamesContractResolver() + ContractResolver = new CamelCasePropertyNamesContractResolver(), + Culture = CultureInfo.InvariantCulture }; /// @@ -74,13 +76,14 @@ namespace Newtonsoft.Json /// /// The type of the instance to deserialize. /// The JSON string to read the values from. + /// A fallback value. /// A new instance of with the deserialized values. - public static T DeserializeJson(this string json) + public static T DeserializeJson(this string json, T fallback = default) { if (!string.IsNullOrWhiteSpace(json)) return JsonConvert.DeserializeObject(json, jsonSerializerSettings); - return default; + return fallback; } ///