I create json object like this
id json = [NSJSONSerialization JSONObjectWithData:data
options:kNilOptions
Here is one way to do it. I'll be happy to get into more details if you make your question more specific.
NSString *jsonString = @"[{\"id\": \"1\", \"name\":\"Aaa\"}, {\"id\": \"2\", \"name\":\"Bbb\"}]";
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *e = nil;
NSArray *jsArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&e];
if (!jsArray) {
NSLog(@"Error parsing JSON: %@", e);
} else {
for(NSDictionary *item in jsArray) {
NSLog(@"Item: %@", item);
NSLog(@"%@",[item objectForKey:@"id"]);
NSLog(@"%@",[item objectForKey:@"name"]);
}
}