iOS:我如何从数组中的对象中获取值,它在一个字典中?
我得到的JSON如下:iOS:我如何从数组中的对象中获取值,它在一个字典中?,ios,objective-c,nsarray,nsdictionary,Ios,Objective C,Nsarray,Nsdictionary,我得到的JSON如下: { response = { message = ( "Permission denied, you do not have permission to access the requested page." ); }; } 我想打印: 权限被拒绝,您没有访问请求页面的权限 如何获得目标C中的值? NSArray *arrRes = [[jsonRes objectForKey:@"respon
{
response = {
message = (
"Permission denied, you do not have permission to access the requested page."
);
};
}
我想打印:
权限被拒绝,您没有访问请求页面的权限
如何获得目标C中的值?
NSArray *arrRes = [[jsonRes objectForKey:@"response"] objectForkey:@"message"];
NSLog(@"The output result is - %@",arrRes);
然后,如果要打印数组中的字符串,请执行以下操作
for(int i=0;i<arrRes.count;i++){
NSString *strRes = arrRes[i];
NSLog(@"The strRes is - %@",strRes);
}
for(int i=0;i读大括号/圆括号{}
是字典,键下标()
为数组,下标为索引。字符串是根字典中keyresponse
的字典中keymessage
的数组中的第一项。尝试将JSON解析作为第一步,您将了解其余内容。这将对您有所帮助-