[Document] Json.Net

Posted arcsinw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Document] Json.Net相关的知识,希望对你有一定的参考价值。

1.JsonConverter

简单的将一个对象序列化,不做其他处理

JsonConverter.SerializeObject(object);

2.JsonSerializer

对序列化提供更多的控制

 2.1 DateFormatHandling 控制时间的序列化

 技术分享图片

   并没有yyyy-MM-dd 类似的格式,看来要自己写

 2.2 MissingMemberHandling

 当json中有的属性实体类中没有时的处理

技术分享图片

 2.3 ReferenceLoopHandling 循环引用处理

技术分享图片

  2.4 NullValueHandling 空值处理

    两种情况 对象中有个属性没有值时的序列化处理;json中有个属性没有值的反序列化处理

技术分享图片

  可以通过JsonPropertyAttribute自定义

  2.5 DefaultValueHandling 默认值处理

技术分享图片

 可以自定义

 2.6 ObjectCreationHandling

  控制反序列化过程中对象如何被生成和反序列化

 技术分享图片

 可自定义

 2.7 TypeNameHandling

  

TypeNameHandling controls whether Json.NET includes .NET type names during serialization with a $type property and reads .NET type names from that property to determine what type to create during deserialization.

The value of the $type property can be customized and validated by creating your own SerializationBinder.

 

技术分享图片

 2.8 TypeNameAssemblyFormat

 控制序列化的时候类型名的写法

技术分享图片

 

参考链接

http://www.newtonsoft.com/json/help/html/Introduction.htm

以上是关于[Document] Json.Net的主要内容,如果未能解决你的问题,请参考以下文章

document.domain = document.domain 有啥作用?

document.domain = document.domain 有啥作用?

document.querySelector()方法document.querySelectorA()

如何获取document?

javascript document.createElement() document.createTextNode()

$(document).height()$(document).scrollTop()