c# Newtonsoft.Json 解析Json问题
{{"pagesize":100,"page":1,"count":"4946","auth":0,"list":[{"url":"222","k_url":"22","...
{{
"pagesize": 100,
"page": 1,
"count": "4946",
"auth": 0,
"list": [
{
"url": "222",
"k_url": "22",
"w_id": "555",
"we": "555"
},
{
"url": "woguohk",
"k_url": "",
"w_id": "",
"we": "222"
}
],
"status": 0
}}
问大神,请问这个怎么用Newtonsoft.Json;把他解析出来,输出所有的list中的 url的值 展开
"pagesize": 100,
"page": 1,
"count": "4946",
"auth": 0,
"list": [
{
"url": "222",
"k_url": "22",
"w_id": "555",
"we": "555"
},
{
"url": "woguohk",
"k_url": "",
"w_id": "",
"we": "222"
}
],
"status": 0
}}
问大神,请问这个怎么用Newtonsoft.Json;把他解析出来,输出所有的list中的 url的值 展开
1个回答
展开全部
这个json格式不正确,你必须把两边的大括号各去掉一个,然后使用JsonConvert<dynamic>
如:
var model = JsonConvert.DeserializeObject<dynamic>("{\"pagesize\":100,\"page\":1,\"count\":\"4946\",\"auth\":0,\"list\":[{\"url\":\"222\",\"k_url\":\"22\",\"w_id\":\"555\",\"we\":\"555\"},{\"url\":\"woguohk\",\"k_url\":\"\",\"w_id\":\"\",\"we\":\"222\"}],\"status\":0}");
foreach (var item in model.list)
{
Console.WriteLine(item + "\r\n");
}
如:
var model = JsonConvert.DeserializeObject<dynamic>("{\"pagesize\":100,\"page\":1,\"count\":\"4946\",\"auth\":0,\"list\":[{\"url\":\"222\",\"k_url\":\"22\",\"w_id\":\"555\",\"we\":\"555\"},{\"url\":\"woguohk\",\"k_url\":\"\",\"w_id\":\"\",\"we\":\"222\"}],\"status\":0}");
foreach (var item in model.list)
{
Console.WriteLine(item + "\r\n");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询