我无法使用 Json.net 库解析下面的 json。如果对象出现在对象中,我会感到困惑。我正在使用 JSON.net 库并且能够获取除“列表”对象之外的数据。请帮忙。
@"{""status"":1, ""list"":
{""231784875"":
{
""item_id"":""231784875"",
""title"":""ASP.Net Skill Test, ASP.Net quiz, ASP.Net Online Tests, Online Assessments,"",
""url"":""http:\/\/www.techgig.com\/skilltest\/ASP-Net"",
""time_updated"":""1351228692"",
""time_added"":""1349344004"",
""state"":""1""
}
}
,""since"":1351228692,
""complete"":0
}";
请检查我的以下代码
private void ReadWebRequestCallback(IAsyncResult callbackResult)
{
HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult);
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
string results = httpwebStreamReader.ReadToEnd();
JObject o= JObject.Parse(results);
JArray list = (JArray) o[o["list"]];
//getting error
}
myResponse.Close();
}
错误描述
Accessed JObject values with invalid key value: {
"211384805": {
"item_id": "211384805",
"title": "Introduction | Developer Portal",
"url": "https://developer.uidai.gov.in/site/node/19",
"time_updated": "1351109730",
API 提供者的 JSON 结构
下面是来自 API 提供者的 Json 结构。
{
"status":"1", // 1=normal, 2=no changes since your provided 'since'
"since":"1245626956', // timestamp of this response
"list":{
"93817":{
"item_id":"93817" // unique id identifying the url
"url":"http://url.com",
"title":"Page Title",
"time_updated":"1245626956", // time the item was last added/changed
"time_added":"1245626956", // time item was added to list
"tags":"comma,seperated,list",
"state":"0", // 0=unread, 1=read
},
"935812":{
"item_id":"935812" // unique id identifying the url
"url":"http://google.com",
"title":"Google",
"time_updated":"1245626956", // time the item was last added/changed
"time_added":"1245626956", // time item was added to list
"tags":"comma,seperated,list",
"state":"1", // 0=unread, 1=read
}
}
}