-
// Your JSON data: - NSString *colorArray = @"[{ \"color\":\"Red\" },{ \"color\":\"Blue\" },{ \"color\":\"Yellow\"}]";
- NSLog(@"colorArray=%@", colorArray);
- // Convert to JSON object:
- NSArray *jsonObject = [NSJSONSerialization JSONObjectWithData:[colorArray dataUsingEncoding:NSUTF8StringEncoding]
- options:0 error:NULL];
- NSLog(@"jsonObject=%@", jsonObject);
- // Extract "color" values:
- NSArray *tableData = [jsonObject valueForKey:@"color"];
- NSLog(@"tableData=%@", tableData);
当参数为nsarray时,将已有的NSArray转为NSString
最新推荐文章于 2016-08-27 14:17:56 发布