Newtonsoft.Json序列化和反序列

前端之家收集整理的这篇文章主要介绍了Newtonsoft.Json序列化和反序列前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

//把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'}] .

猜你在找的Json相关文章