首页 > Windows开发 > 详细

Newtonsoft.Json(C#处理json)

时间:2015-01-17 11:11:30      阅读:298      评论:0      收藏:0      [点我收藏+]

转载自:http://blog.csdn.net/wswqiang/article/details/6783161

using Newtonsoft.Json;
using System.Text;

StringBuilder sb = new StringBuilder();
                string str = "[{ID:‘1‘,Name:‘John‘,Other:[{Age:‘21‘,Sex:‘0‘}]},{ID:‘2‘,Name:‘Good‘,Other:[{Age:‘36‘,Sex:‘1‘}]}]";
                JavaScriptArray javascript = (JavaScriptArray)JavaScriptConvert.DeserializeObject(str);

                for (int i = 0; i < javascript.Count; i++ )
                {
                    JavaScriptObject obj = (JavaScriptObject)javascript[i];
                    sb.Append("ID:" + obj["ID"].ToString());
                    sb.Append("Name:" + obj["Name"].ToString());
                    JavaScriptArray json = (JavaScriptArray)obj["Other"];

                    for (int j = 0; j < json.Count; j++){
                        JavaScriptObject jsonobj = (JavaScriptObject)json[j];
                        sb.Append("Age:" + jsonobj["Age"].ToString());
                        sb.Append("Sex:" + jsonobj["Sex"].ToString());
                    }
                }

 

Newtonsoft.Json(C#处理json)

原文:http://www.cnblogs.com/wangzhenghua/p/4230176.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!