首页 > 代码库 > IOS - JSON数据解析 小3种方法
IOS - JSON数据解析 小3种方法
[manager GET:serverURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
// 3 解析返回的JSON数据
// 3.1
// NSDictionary *result1 = (NSDictionary *)responseObject;
// 3.2
// NSString *requestTmp = [NSString stringWithString:operation.responseString];
// NSData *resData = [[NSData alloc] initWithData:[requestTmp dataUsingEncoding:NSUTF8StringEncoding]];
// NSDictionary *result2 = [NSJSONSerialization JSONObjectWithData:resData options:NSJSONReadingMutableLeaves error:nil];
// NSLog(@"response:%@",responseObject);
// 3.3
NSData *responseData = http://www.mamicode.com/[NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:nil];
NSDictionary *result3 = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:nil];
IOS - JSON数据解析 小3种方法