正确的JSON应该看起来像这样:
[ { "id": "value", "array": [{"id": "value"},{"id": "value"}] }, { "id": "value", "array": [{"id": "value"},{"id": "value"}] }]
NSJSONReadingMutableContainers然后
NSJSONSerialization针对每个
array条目再次调用:
NSMutableArray *array = [NSJSonSerialization JSONObjectWithdata:data options:NSJSonReadingMutableContainers error:&error];if (error) NSLog(@"JSonObjectWithData error: %@", error);for (NSMutableDictionary *dictionary in array){ NSString *arrayString = dictionary[@"array"]; if (arrayString) { NSData *data = [arrayString dataUsingEncoding:NSUTF8StringEncoding]; NSError *error = nil; dictionary[@"array"] = [NSJSonSerialization JSONObjectWithdata:data options:0 error:&error]; if (error) NSLog(@"JSonObjectWithData for array error: %@", error); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)