This commit is contained in:
@@ -7,9 +7,9 @@ namespace SuccessfulCodeTools.Extensions
|
||||
{
|
||||
public static class ObjectExtensions
|
||||
{
|
||||
public static Lazy<JsonSerializerSettings> _settings = new Lazy<JsonSerializerSettings>(GetSettings);
|
||||
public static Lazy<JsonSerializerSettings> _settings = new Lazy<JsonSerializerSettings>(JsonSettings);
|
||||
|
||||
private static JsonSerializerSettings GetSettings()
|
||||
private static JsonSerializerSettings JsonSettings()
|
||||
{
|
||||
var settings = new JsonSerializerSettings()
|
||||
{
|
||||
|
||||
@@ -7,9 +7,18 @@ namespace SuccessfulCodeTools
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static T DeserializeJson<T>(this string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex = new ArgumentException("Not valid json", nameof(value), ex);
|
||||
ex.Data.Add("argument value", value);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public static T ToEnum<T>(this string value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user