加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Newtonsoft.Json序列化和反序列

发布时间:2020-12-16 19:58:07 所属栏目:百科 来源:网络整理
导读://把 Json 字符串反序列化为对象 目标对象= JavaScriptConvert.DeserializeObject(JSON字符串, typeof (目标对象)); //把目标对象序列化为 Json 字符串 string Json 字符串 = JavaScriptConvert .SerializeObject(目标对象); 这里下载:http://www.newtonsoft

//把Json 字符串反序列化为对象
目标对象= JavaScriptConvert.DeserializeObject(JSON字符串,typeof (目标对象));
//把目标对象序列化为Json 字符串

string

Json
字符串 = JavaScriptConvert .SerializeObject(目标对象);

这里下载:http://www.newtonsoft.com/products/json/
安装:
1. 解压下载文件,得到Newtonsoft.Json.dll
2.在项目中添加引用..
序列化和反序列在.net项目中:

读取JSON

结果显示:

TokenType ValueType Value
StartArray null null
String System.String JSON!
Integer System.Int32 1
Boolean System.Boolean True
StartObject null null
PropertyName System.String property
String System.String value
EndObject null null

EndArray

null

null

l

这里会打印出: ['JSON!',{property:'value'}] .

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读