一,工程图。

【代码笔记】iOS-json文件的两种解析方式

二,代码。

【代码笔记】iOS-json文件的两种解析方式
#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文件的两种解析方式

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-11-18
  • 2022-01-14
  • 2022-12-23
  • 2021-07-22
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-10-05
  • 2021-11-17
相关资源
相似解决方案