【发布时间】:2015-05-06 15:51:34
【问题描述】:
我正在尝试正确定位 Json 输出中的元素,并且我越来越接近,但我认为我缺少一种简单而明显的方法。
我的 Json 看起来像这样,带有上层事件。
JSON 片段已更新
chat = (
(
{
Key = senderId;
Value = {
Type = 0;
Value = "eu-west-1:91afbc3f-890a-4160-8903-688bf0e9efe8";
};
},
{
Key = chatId;
Value = {
Type = 0;
Value = "eu-west-1:be6457ce-bac1-412d-9307-e375e52e22ff";
};
},
{
Key = timestamp;
Value = {
Type = 1;
Value = 1430431197;
};
},
//Continued
我的目标是使用
NSArray *chat = array[@"chat"];
for ( NSDictionary *theCourse in chat )
{
NSLog(@"---- %@", theCourse);
// I tried the following to target the values
//NSLog(@"chatId: %@", [theCourse valueForKey:@"Key"]);
//NSLog(@"timestamp: %@", theCourse[@"senderId"] );
}
}
我需要解析每个键的值数据,如果我使用数组会像 [theCourse valueForKey:@"Key"] 那样做,但我认为我可能不够深入?
如您所料,[theCourse valueForKey:@"Key"] 给了我键值,但我需要这些键的关联值。
【问题讨论】:
-
chat 看起来不像是一个字典数组。它看起来像一个字典数组。
标签: ios objective-c json nsdictionary