#序列化时,忽略jsonproperty特性的作用:
public static class JsonConvertExtension { public static string CustomSerialize(object obj) { JsonSerializerSettings settings = new JsonSerializerSettings(); settings.Formatting = Formatting.Indented; settings.ContractResolver = new IgnoreJsonPropertyContractResolver(); return JsonConvert.SerializeObject(obj, settings); } private class IgnoreJsonPropertyContractResolver : DefaultContractResolver { protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization) { IList<JsonProperty> list = base.CreateProperties(type, memberSerialization); foreach (JsonProperty prop in list) { prop.PropertyName = prop.UnderlyingName; } return list; } } }
执行:
参考链接:http://www.imooc.com/wenda/detail/586354
标签:settings,memberSerialization,list,prop,JsonConvert,static,相关,操作 From: https://www.cnblogs.com/wushijin/p/11868051.html