本地读取Json失败
2016-09-27 14:23
423 查看
直接向读取数组一样的 _AllARY = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Address" ofType:@"plist"]];
失败,则可以
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"city" ofType:@"json"];
NSLog(@"filePath: %@", filePath);
NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
NSLog(@"jsonData: %@", jsonData);
NSError *error = nil;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments|NSJSONReadingMutableLeaves error:&error];
NSLog(@"jsonDict: %@", jsonDict);
NSLog(@"error: %@", error);
失败,则可以
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"city" ofType:@"json"];
NSLog(@"filePath: %@", filePath);
NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
NSLog(@"jsonData: %@", jsonData);
NSError *error = nil;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments|NSJSONReadingMutableLeaves error:&error];
NSLog(@"jsonDict: %@", jsonDict);
NSLog(@"error: %@", error);
相关文章推荐
- windows 8 metro app 读取本地json的方法
- android应用将json数据打包在本地,进行读取的代码
- ios-本地项目下 json文件的读取
- Android项目如何从本地读取JSON字符串
- 关于JQuery加载本地JSON文件无法读取(权限不足的)解决
- 使用Ext.Extend:使用Ext的JsonReader读取本地数据实现grid分页
- JavaScript读取本地json文件
- iOS国家城市选择器 读取本地json文件
- pyhton 从web获取json数据 保存到本地然后再读取
- 如何读取本地的json数据
- 关于chrome浏览器下使用js读取本地json文件时提示“Origin null is not allowed by Access-Control-Allow-Origin”问题
- java 读取本地的json文件
- android 读取本地的json文件
- BaseAdapter,这篇博客讲深入一些,实现从本地的JSON文件读取数据
- android 读取本地json文件 解决显示乱码显示
- 读取本地JSON文件并显示
- Jquery加载本地json失败
- java 读取本地的json文件
- jQuery的getJSON方法不支持本地文件读取,一定要在服务器当中
- 从本地JSON文件中读取数据