Youtubeプレイリストを解析しようとしています:
JSON が次のように構成されている場合:
{"apiVersion" ....
"items":[{"id2":"some-id","title":"songtitle",
次の方法でタイトルを完全に解析できます。
// Fill array
NSArray *items = [json objectForKey:@"items"];
// Get item from tableData
NSDictionary *item = [tableData objectAtIndex:[indexPath row]];
// Set text on textLabel
[[cell textLabel] setText:[item objectForKey:@"title"]];
しかし、JSON が次のような場合:
{"apiVersion" ....
"items":[{"id1": .... "video":{"id2":"some-id","title":"songtitle",
ネストされたオブジェクトのタイトルに到達するにはどうすればよいですか?
単純なことですが、私はこれについて何時間も頭を悩ませています。いらいらします、あなたの提案をありがとう!
[編集] これは完全な構造です:
{
"items":
[
{
"video":
{
"title": "Number One",
"description": "Description one"
},
{
"title": "Number two",
"description": "Description two"
},
{
"title": "Number three",
"description": "Description three"
}
},
{
"video":
{
"title": "Number One",
"description": "Description one"
},
{
"title": "Number two",
"description": "Description two"
},
{
"title": "Number three",
"description": "Description three"
}
}
]
}