json解析NSJSONSerialization方法

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>


//    //1、json转换成对象

//    NSString * path = [[NSBundle mainBundle] pathForResource:@"test.json" ofType:nil];

//    NSData * data = [NSData dataWithContentsOfFile:path];

//    NSDictionary * dic = [ NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];

//    NSArray * array = dic[@"class1"];

//    

//    for (NSDictionary * dic in array)

//    {

//        

//    //2.对象转成data

//        NSData * data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];

//        NSString * str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

//        NSLog(@"%@", str);

//        

//    }