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 = [NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:nil];

NSDictionary *result3 = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:nil];

上一篇:IP地址 0.0.0.0 是什么意思?


下一篇:HDU 5607 graph(矩阵乘法)