JsonConverte扩展
public static class JsonHelper
{
public static string SerializeObject(this object obj)
{
return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
DateFormatString = "yyyy-MM-dd HH:mm:ss"
});
}
public static T DeserializeObject<T>(this string data)
{
return JsonConvert.DeserializeObject<T>(data, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
}