分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

[Document] Json.Net

发布时间:2023-09-06 01:44责任编辑:赖小花关键词:暂无标签

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

原文地址:https://www.cnblogs.com/arcsinw/p/6082699.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved