标签:blog ring serial span new eof ret att and
1 static class JsonHelper 2 { 3 public static string ToJson(this object obj) 4 { 5 var str = JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings 6 { 7 NullValueHandling = NullValueHandling.Ignore, 8 DateFormatString = "yyyy-MM-dd HH:mm:ss", 9 ReferenceLoopHandling = ReferenceLoopHandling.Ignore//循环引用 10 }); 11 return str; 12 } 13 14 public static T FromJson<T>(this string json) where T : class 15 { 16 return JsonConvert.DeserializeObject(json, typeof(T), new IsoDateTimeConverter 17 { 18 DateTimeFormat = "yyyy-MM-dd HH:mm:ss" 19 }) as T; 20 } 21 }
标签:blog ring serial span new eof ret att and
原文地址:http://www.cnblogs.com/jonney-wang/p/7576065.html