【发布时间】:2017-01-24 20:19:59
【问题描述】:
[
{
"c_name" : "r",
"email_id" : "r",
"phn_no" : "2",
"c_id" : "1"
},
{
"c_name" : "e",
"email_id" : "e",
"phn_no" : "4",
"c_id" : "2"
}
]
这是我收到的 JSON 字符串输出。现在如何访问这些数据?我用NSJSONSerialization类:
NSError *writeError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr_mcontacts options:NSJSONWritingPrettyPrinted error:&writeError];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"JSON Output: %@",jsonString);
【问题讨论】:
-
你已经在 json 中有数据了。在您将其序列化为 json 之前,它就是您的
arr_mcontacts中的内容。 -
过去有成百上千个关于如何使用 NSJSONSerialization 解析 json 数据的问题。在所有这些问题中,你不明白具体是哪一个具体部分怎么办?到目前为止,您尝试过什么?
标签: ios objective-c json