我正在尝试解析 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"
}
}
]
}