IPHONE JSON 一个例子

Objective-C

Works with:  Mac OS X version 10.7+
untested
NSString *json_string = @"{ \"foo\": 1, \"bar\": [10, \"apples\"] }"id obj =[NSJSONSerialization JSONObjectWithData:[json_string dataUsingEncoding:NSUTF8Encoding] options:0 error:NULL]; NSLog(@"%@", obj);   idobj2 = [NSDictionary dictionaryWithObjectsAndKeys:[NSArrayarrayWithObjects:[NSNumber numberWithInt:1][NSNumber numberWithInt:2]nil],@"blue"@"water"@"ocean"nil]NSString *json_string2 = [[[NSString alloc]initWithData:[NSJSONSerialization dataWithJSONObject:obj2 options:0 error:NULL]encoding:NSUTF8Encoding] autorelease]; NSLog(@"%@", json_string2);

你可能感兴趣的:(IPHONE JSON 一个例子)