到目前为止,我只解析了初始阵列上的JSON,但我不确定如何继续。
这是我的JSON:
{
"SongDeviceID": [
{
"SID": "714",
"SDID": "1079287588763212246"
},
{
"SID": "715",
"SDID": "1079287588763212221"
},
{
"SID": "716",
"SDID": "1079287588763212230"
}
]
}
以下是我目前在代码中的内容:
NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData: jsonResponse options: NSJSONReadingMutableContainers error: &e];
NSArray * responseArr = [NSArray arrayWithObject:jsonResponse];
for (NSDictionary *dict in responseArr)
我认为即时通讯是错误的,因为我过去只有一层深度JSON响应,有人可以帮助我吗?
答案 0 :(得分:1)
你很亲密。你需要:
NSDictionary *jsonArray = [NSJSONSerialization JSONObjectWithData: jsonResponse options: NSJSONReadingMutableContainers error: &e];
NSArray * responseArr = jsonArray[@"SongDeviceID"];
for (NSDictionary *dict in responseArr) {
// dict has two keys - SID and SDID
}