{"Overviews":
[
{"AAAA": [
{"Generala": "sometext",
"Generalb": "sometext",
"Generalc": "sometext"}
],
"BBBB": [
{"Generala": "sometext",
"Generalb": "sometext",
"Generalc": "sometext"}
]
}
]
}
Hi I used SBJson to parse this json. When I assigned NSArray *json = [jsonObject valueForKey:@”Overviews”];. The hierarchy of data didn’t go well. I used one NSDictionary, 2 NSArray and 1 NSString to parse Generala.
My goal is to parse the data “Generala” like this:
NSDictionary *data = [overviews valueForObject:@"AAAA"];
NSString *generals = [data valueForObject:@"Generala"];
What have I done wrong in the json file? Thanks in advance.
This will get you to the correct value, But as you can see I had to “Hard code” the index “0”. You would want some logic in there to get to the specific array.
or Change your json to:
and use:
NSDictionary *dataDict = [overviews objectForKey:@”AAAA”];
NSString *string = [dataDict objectForKey:@”Generala”];