I have a very complex JSON data. And I tried to parse using objective c programming. The JSON data looks like the following (Here, I presented the simple format to explain. But it has very deep leveling):
{
"university": "CUNY",
"results": {
"Engineering": 200,
"Computer Science": 298,
"Life Science": 28
}
}
Using NSJSONSerialization
, I tried to solve this and I use the following code:
NSDictionary *parsedObject = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
[parsedObject objectForKey:@"results"];
And getting the result. But I need a dictionary like myResultDict
which will be made form the results
so that I can implement other functionality.
Can anybody give me a small hint how to do that?
When you get the parsed data by using
NSJSONSerialization
it will give you parsed dictionary with multiple key-value pairs.Then by fetching results key you can get your result dictionary.
For example: