保存一下iOS 读取Json的代码,留着以后Copy用,哈哈。
NSString* path = [[NSBundle mainBundle] pathForResource: @"Sandwiches" ofType: @"json"]; NSString* data = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding error: nil]; NSData* resultData = [data dataUsingEncoding:NSUTF8StringEncoding]; _sandwiches = [NSJSONSerialization JSONObjectWithData:resultData options:kNilOptions error:nil];
json文件,或者从网络读取的json,如图
时间: 2024-11-08 13:23:57