Newtonsoft.json怎么解析多层Json
{"data":{"__CU":{"uid":20952422,"group_bit":622816},"__GLOBAL":"./template/js/nga_glo...
{
"data": {
"__CU": {
"uid": 20952422,
"group_bit": 622816
},
"__GLOBAL": "./template/js/nga_global.xml",
"__F": {
"topped_topic": 1565495,
"sub_forums": {
"0": {
"0": 255,
"1": "安安宝贝",
"2": ""
},
"1": {
"0": 338,
"1": "彻彻底底",
"2": ""
}
},
"__SELECTED_FORUM": "7,255"
},
"__T": {
"0": {
"tid": 6970086,
"fid": 7
},
"1": {
"tid": 6969997,
"fid": 7
}
}
},
"encode": "gbk",
"time": 1396180308
}
就是上面的这个东西 用C#怎么能够方便的获取tid,fid等内容 展开
"data": {
"__CU": {
"uid": 20952422,
"group_bit": 622816
},
"__GLOBAL": "./template/js/nga_global.xml",
"__F": {
"topped_topic": 1565495,
"sub_forums": {
"0": {
"0": 255,
"1": "安安宝贝",
"2": ""
},
"1": {
"0": 338,
"1": "彻彻底底",
"2": ""
}
},
"__SELECTED_FORUM": "7,255"
},
"__T": {
"0": {
"tid": 6970086,
"fid": 7
},
"1": {
"tid": 6969997,
"fid": 7
}
}
},
"encode": "gbk",
"time": 1396180308
}
就是上面的这个东西 用C#怎么能够方便的获取tid,fid等内容 展开
1个回答
展开全部
原理如下
// using Newtonsoft.Json.Linq;
var jObject = JObject.Parse(testString);
Console.WriteLine(jObject["data"]["__T"]["0"]["tid"]); ;
Console.WriteLine(jObject["data"]["__T"]["0"]["fid"]); ;
Console.WriteLine(jObject["data"]["__T"]["1"]["tid"]); ;
Console.WriteLine(jObject["data"]["__T"]["1"]["fid"]); ;
Console.ReadKey();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询