本文实例讲述了C#格式化json字符串的方法。分享给大家供大家参考,具体如下:
将Json字符串转化成格式化表示的方法: 字符串反序列化为对象-->对象再序列化为字符串
使用Newtonsoft.Json提供的API,下载地址:http://www.newtonsoft.com/json
很多时候我们需要将json字符串以
{
"status": 1,
"sum": 9
}
这种方式显示,而从服务端取回来的时候往往是这样
什么?无所谓?
如果数据很庞大的时候,比如这样
[url=http://tools.jb51.net/code/json]http://tools.jb51.net/code/json[/url]
[b]JSON[/b][b]在线格式化工具:
[/b][url=http://tools.jb51.net/code/jsonformat]http://tools.jb51.net/code/jsonformat[/url]
[b]在线XML/JSON互相转换工具:
[/b][url=http://tools.jb51.net/code/xmljson]http://tools.jb51.net/code/xmljson[/url]
[b]json[/b][b]代码在线格式化/美化/压缩/编辑/转换工具:
[/b][url=http://tools.jb51.net/code/jsoncodeformat]http://tools.jb51.net/code/jsoncodeformat[/url]
[b]在线json压缩/转义工具:[/b]
[url=http://tools.jb51.net/code/json_yasuo_trans]http://tools.jb51.net/code/json_yasuo_trans[/url]
更多关于C#相关内容还可查看本站专题:《[url=http://www.1sucai.cn/Special/261.htm]C#字符串操作技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/165.htm]C#常见控件用法教程[/url]》、《[url=http://www.1sucai.cn/Special/125.htm]WinForm控件用法总结[/url]》、《[url=http://www.1sucai.cn/Special/227.htm]C#程序设计之线程使用技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/266.htm]C#中XML文件操作技巧汇总[/url]》、《[url=http://www.1sucai.cn/Special/116.htm]C#数据结构与算法教程[/url]》、《[url=http://www.1sucai.cn/Special/265.htm]C#数组操作技巧总结[/url]》及《[url=http://www.1sucai.cn/Special/478.htm]C#面向对象程序设计入门教程[/url]》
希望本文所述对大家C#程序设计有所帮助。