Newtonsoft.Json(C#处理json)

转载自: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 = ; 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 = ; j < json.Count; j++){
JavaScriptObject jsonobj = (JavaScriptObject)json[j];
sb.Append("Age:" + jsonobj["Age"].ToString());
sb.Append("Sex:" + jsonobj["Sex"].ToString());
}
}
上一篇:vb- ----之常用函数


下一篇:golang RWMutex读写锁分析