【发布时间】:2013-11-26 08:46:29
【问题描述】:
我的服务器返回了一些 Json 类型的 NSData。我想知道如何访问 json 中存在的值并将它们放入自己的 NSString 对象中。
JsonArray 的结构是这样的
这是我正在使用的代码,但是我的 for 循环只显示“结果”而没有其他任何内容。
NSError *error = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:csvData options: NSJSONReadingMutableContainers error: &error];
NSLog(@"%@", jsonArray);
if (!jsonArray) {
NSLog(@"Error parsing JSON: %@", error);
} else {
for(NSDictionary *item in jsonArray) {
NSLog(@"Item: %@", item);
}
}
【问题讨论】:
-
看起来您的数组包含字典。你的字典有一个字符串作为键,另一个数组作为值。休息由你决定
标签: ios objective-c json nsarray