标签:style blog color io ar for sp div c
代码:
#import <Foundation/Foundation.h> void parseJSON(NSString *text) { NSError *error = nil; NSData *data = [text dataUsingEncoding:NSUTF8StringEncoding]; NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; if (error != nil) { NSLog(@"has error"); return; } for (int i=0; i < array.count; i++) { NSDictionary *dict = array[i]; id bookid = [dict objectForKey:@"bookid"]; NSLog(@"bookid = %d", [bookid intValue]); NSString *name = [dict objectForKey:@"name"]; NSLog(@"name = %@", name); } } int main(int argc, const char * argv[]) { @autoreleasepool { parseJSON(@"[{\"bookid\":123,\"name\":\"笑傲江湖\"}]"); } return 0; }
标签:style blog color io ar for sp div c
原文地址:http://www.cnblogs.com/code-style/p/4011343.html