我从 Web 服务获取此 JSON:
{
"Respons": [{
"status": "101",
"uid": "0"
}]
}
我尝试使用以下方法访问数据:
NSError* error;
//Response is a NSArray declared in header file.
self.response = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSString *test = [[self.response objectAtIndex:0] objectForKey:@"status"]; //[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance
NSString *test = [[self.response objectForKey:@"status"] objectAtIndex:0]; //(null)
但是它们都不起作用,如果我 NSLog 保存序列化数据的 NSArray,这就是我得到的:
{
Respons = (
{
status = 105;
uid = 0;
}
);
}
我如何访问数据?