将Json存进本地文件夹
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path=[paths objectAtIndex:0];
NSString *Json_path=[path stringByAppendingPathComponent:@
"JsonFile.json"
];
NSLog(@
"%@"
,[JsonData writeToFile:Json_path atomically:YES] ? @
"Succeed"
:@
"Failed"
);
-----------------------
读取Json
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path=[paths objectAtIndex:0];
NSString *Json_path=[path stringByAppendingPathComponent:@
"JsonFile.json"
];
NSData *data=[NSData dataWithContentsOfFile:Json_path];
id JsonObject=[NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingAllowFragments
error:&error]