Newtonsoft.Json的格式化设置
var jsonSetting = new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore};
序列化和反序列化时,忽略null字段
var ArticleList = JsonConvert.DeserializeObject<List<ArticleTask>>(json,jsonSetting);
---------------------------------------
new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }
序列化时,对时间的格式化设定,使用方法
var json = JsonConvert.SerializeObject(requestData, Formatting.Indented, new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" });
忽略自循环
var settings = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; Log4NetHelper.Debug(JsonConvert.SerializeObject(call,Formatting.Indented,settings));