iOS 5 now has everything needed to do that :
NSError *error = nil;
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:filepath append:yesOrNo];
[outputStream open];
[NSJSONSerialization writeJSONObject:nsDicOrNSArrayObject
toStream:outputStream
options:0
error:&error];
[outputStream close];
JSONKit还具有从NSArrays和NSDictionarys检索JSON值所需的一切。
NSString *jsonString = [yourDictionary JSONString];
Have you tried SBJson ? I've used it for both parsing and generation of JSON in several projects.
NSData *json1= [ NSJSONSerialization dataWithJSONObject :info options:NSJSONWritingPrettyPrinted error:&error];
如果要将字典转换为json数据,请使用dataWithJSONObject
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.