Open Source Web Application Framework for ASP.NET Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
552 B

using System;
using Newtonsoft.Json;
namespace LocalizationKeySynchronizer;
public static class JsonHelper
{
public static bool TryDeserialize<T>(string json, out T? result)
{
try
{
result = JsonConvert.DeserializeObject<T>(json);
return true;
}
catch (Exception)
{
result = default;
return false;
}
}
public static string Serialize<T>(T value)
{
return JsonConvert.SerializeObject(value, Formatting.Indented);
}
}