我試圖解析一個YouTube播放列表:iOS 5谷歌JSON - 如何解析嵌套的對象?
如果我的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",
我怎樣才能達到嵌套目標ct標題?
只是一個簡單的事情,但我現在敲我的頭在這幾個小時。感到沮喪,謝謝你的建議!
[編輯] 這是一個完整的結構:
{
"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"
}
}
]
}
你能證明你的整個JSON ,它有點混淆這種方式... – 2012-04-24 12:41:48