25 lines
684 B
C#
25 lines
684 B
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
namespace CorePush.Utils
|
|
{
|
|
public static class JsonHelper
|
|
{
|
|
private static readonly JsonSerializerSettings settings = new JsonSerializerSettings
|
|
{
|
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
|
NullValueHandling = NullValueHandling.Ignore,
|
|
};
|
|
|
|
public static string Serialize(object obj)
|
|
{
|
|
return JsonConvert.SerializeObject(obj, settings);
|
|
}
|
|
|
|
public static TObject Deserialize<TObject>(string json)
|
|
{
|
|
return JsonConvert.DeserializeObject<TObject>(json, settings);
|
|
}
|
|
}
|
|
}
|