JSON序列化自己主动过滤NULL值
2021-06-21 18:06
标签:new pos pre ade newton orm des article ted 使用Newtonsoft.Json.dll 序列化为json时主动将NULL值过滤掉。详细做法: 之前转换的JSON为: 參加代码后转换出来的为:
JSON序列化自己主动过滤NULL值 标签:new pos pre ade newton orm des article ted 原文地址:http://www.cnblogs.com/zhchoutai/p/7181412.htmlvar jSetting = new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore};
var json = JsonConvert.SerializeObject(response, Formatting.Indented, jSetting);
{"header":{"responseCode":"200","responseDesc"":"运行成功","responseDescErrorMsg":""。"responseDescTime":"2015-07-07T13:40:48.7162196+08:00"}。"body":{"order":{"orderid":"S1507070001"},"product":null}}
{"header":{"responseCode":"200","responseDesc":"运行成功","responseDescErrorMsg":""。"responseDescTime":"2015-07-07T13:40:48.7162196+08:00"},"body":{"order":{"orderid":"S1507070001"}}}