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
});
}
}

posted on   都是脚本惹的祸  阅读(146)  评论(0编辑  收藏  举报

导航

< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10
点击右上角即可分享
微信分享提示