C#用Newtonsoft.Json如何解析这段json,最好能贴出能用的代码
1个回答
展开全部
{
"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
}
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();
"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
}
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();
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询