我不擅长 JSON。我一点都不明白。我的 JSON 响应如下所示:
{
ID = 1;
EDate = "<null>";
SelectedDay = "/Date(-62135596800000)/";
End = "14.09.2013 15:00:00";
Start = "14.09.2013 07:00:00";
SDate = "<null>";
},
{
ID = 1;
EDate = "<null>";
SelectedDay = "/Date(-62135596800000)/";
End = "14.09.2013 16:00:00";
Start = "14.09.2013 07:00:00";
SDate = "<null>";
},
在 NSData 和 NSDictionary 中。例如,如何遍历每个对象的“End”属性,并将它们添加到数组中?
编辑:
我从这段代码登录:
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:result.data options:kNilOptions error:&error];
NSLog(@"Response: %@",dict);
完整的日志是:
最佳答案
这个 JSON 似乎是一个字典数组。尝试:
NSMutableArray *endValuesArray = [[NSMutableArray alloc] init];
for (NSDictionary *dictionary in JSONArray) {
[endValuesArray addObject:[dictionary valueForKey:@"End"]];
}
其中JSONArray是NSJSONSerialization后得到的数组。
关于ios - 从 JSON 响应中提取一个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18947573/