读取模拟数据.json方法
+ (NSDictionary*)catalogue_list_responseObject {
NSData *JSONData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"catalogue" ofType:@"json"]];
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingAllowFragments error:nil];
return dict;
}
- json文件内容如下:
{
"code": "200",
"msg": "success",
"data": {
"categories": [
{
"name": "热门",
"categoryId": "1"
},
{
"name": "户外",
"categoryId": "2"
},
{
"name": "电子昌平",
"categoryId": "3"
},
{
"name": "鞋靴",
"categoryId": "4"
},
{
"name": "珠宝首饰",
"categoryId": "5"
},
{
"name": "美妆",
"categoryId": "6"
},
{
"name": "包袋",
"categoryId": "7"
},
{
"name": "小家电",
"categoryId": "8"
},
{
"name": "母婴",
"categoryId": "9"
},
{
"name": "家具体验",
"categoryId": "10"
}
]
}
}