我目前正在尝试使用json和objective-c但是有点困难.以下是返回的json
{
sethostname = (
{
msgs = "Updating Apache configuration\nUpdating cPanel license...Done. Update succeeded.\nBuilding global cache for cpanel...Done";
status = 1;
statusmsg = "Hostname Changed to: a.host.name.com";
warns = (
);
});
}
Run Code Online (Sandbox Code Playgroud)
我能够检查响应是否会返回并且密钥是sethostname但是无论我尝试什么,我都无法获得例如status或statusmsg的值.任何人都可以指出我在正确的位置.以下是我用来检查是否返回sethostname的基本代码.
NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&myError];
NSLog([res description]);
NSArray *arr;
arr = [res allKeys];
if ([arr containsObject:@"sethostname"])
{
NSLog(@"worked");
}
Run Code Online (Sandbox Code Playgroud)