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
}
}
}