IOS自带json解析类解析json

 - (IBAction)test:(id)sender {
NSString *result = @"{\"code\":\"S00000\",\"message\":\"success\",\"data\":{\"file_name\":\"b1feba4439d0bed9f867123637121b24-dc7764fb24f7294c6a3dcb6971eddb25.png\",\"paths\":[\"x1\",\"x2\",\"x3\",\"x5\",\"x6\",\"x7\",\"x8\",\"xm\"]}}";
NSError *error;
NSData* response = [result dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *jsonInfo = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:&error];
NSString *code = [jsonInfo objectForKey:@"code"]; NSLog([NSString stringWithFormat:@"%@",code]); NSDictionary *data = [jsonInfo objectForKey:@"data"];
NSLog([NSString stringWithFormat:@"%@",[data objectForKey:@"file_name"]]);
}
第6行的NSJSONReadingOption是干嘛的没搞明白 用NSJSONReadingMutableLeaves也能正常解析
上一篇:eclipse java formater 配置详解


下一篇:巨蟒python全栈开发django10:ajax&&登录认证