我只是尝试在Objective-C中部署客户端服务器应用程序。当我进行查询时,我从服务器获得这样的json字符串:
@"{"url":"http://my-company.com/json"}".
如何使用Objective C直接提取the http://my-company.com/json
?
答案 0 :(得分:1)
NSString *jsonString = @"{\"url\":\"http://my-company.com/json\"}";
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *e;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&e];
NSString *url = [jsonDict objectForKey:@"url"];
NSLog(@"url: %@", url);