更改JSON.NET序列化属性名称的方式
问题描述:
如何更改Newtonsoft JSON.NET序列化对象属性名称的方式?
How can I change the way Newtonsoft JSON.NET serializes property names of objects?
答
几种方法:
- 您可以使用
JsonTextWriter
类手动控制其序列化方式:
- You can manually control how it serializes using the
JsonTextWriter
class:- http://james.newtonking.com/projects/json/help/index.html?topic=html/ReadingWritingJSON.htm
- http://james.newtonking .com/projects/json/help/index.html?topic = html/T_Newtonsoft_Json_JsonConverter.htm
- 示例: JSON.NET将序列化自定义为排除属性名称
- http://james.newtonking.com/projects/json/help/index.html?topic=html/T_Newtonsoft_Json_JsonConverter.htm
- Example: JSON.NET customizing the serialization to exclude a property name