我想正确定位Json输出内的元素,并且我越来越近,但我认为这是一种简单而明显的方式。正确解析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"]
给我的关键值,但我需要这些键的关联值。
它看起来不像聊天是一个字典数组。它看起来像一个字典阵列数组。 – gnasher729