姬長信(Redy)

iOS 保存测试数据为json

版权声明/uff1a本文为博主原创文章/uff0c遵循 CC 4.0 by-sa 版权协议/uff0c转载请附上原文出处链接和本声明。
本文链接/uff1ahttps://blog.csdn.net/u011018979/article/details/97629046

数组转json 字符串

(lldb) po [[NSString alloc] initWithData: [NSJSONSerialization dataWithJSONObject:tmp options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding]

json 转数组

NSString *path = [[NSBundle mainBundle] pathForResource:@"city.json" ofType:nil];

NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil];

退出移动版