一,工程图。

ios json数据去掉 n ios json文件_JSON

二,代码。


ios json数据去掉 n ios json文件_json_02



#import "ViewController.h"
#import "SBJson.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    //第一种JSON解析方式,系统自带的JSON解析方式
     NSString * datapath = [[NSBundle mainBundle] pathForResource:@"failureReason" ofType:@"json"];
     NSData * jsonData = [NSData dataWithContentsOfFile:datapath];
     NSMutableDictionary *arrayDic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
     NSLog(@"----arrayDic---%@",arrayDic);
    
    
    //SBJson解析
     NSString *filePath = [[NSBundle mainBundle] pathForResource:@"failureReason" ofType:@"json"];
     NSString *myJSON = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
     NSDictionary *json = [myJSON JSONValue];
    
     NSLog(@"--json--%@",json);

    
    
}



ios json数据去掉 n ios json文件_json_02