- 获取文件路径
NSString * jsonPath = [[NSBundle mainBundle] pathForResource:@"Student" ofType:@"json"];
2.初始化NSData对象
NSData *data = [NSData dataWithContentsOfFile:jsonPath];
3.解析(NSJSONReadingMutableContainers) 可变的一个容器
// NSJSONReadingMutableLeaves
// NSJSONReadingAllowFragments
NSMutableArray * arr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(@"%@",arr);
时间: 2024-10-08 14:08:54