I saved the json
parsing result in a dictionary
which look like:
{
"statusCode":"200",
"body":[
{
"status":"success",
"remarks":null
}
],
"data":[
"abcd":[
{
"category":"a",
"title":"b",
"id":"24"
},
{
"category":"c",
"title":"crd",
"id":"65"
},
{
"category":"ds",
"title":"sd",
"id":"18"
}
]
},
{
"efgh":[
{
"category":"ds",
"title":"sd",
"id":"18"
},
{
"category":"sd",
"title":"sd",
"id":"1"
}
]
},
{
"ijkl":[
{
"category":"ds",
"title":"sd",
"id":"18"
},
{
"category":"sd",
"title":"sd",
"id":"1"
}
]
}
]
}
The data for key @"data" can be saved into an array by using
NSMutableArray *getdata=[[NSMutableArray alloc]init];
getcat=[results objectForKey:@"data"];
Now what should I do for the values(category, title, id)
inside the first index i.e. "abcd"
.
If anyone has any knowledge please look upon that.
Thanks to all.
Following will give you the desired object
NSDictionary *dict=[results valueForKeyPath:@"data.abcd"][0];
For individual:
NSString *categoryString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"Category"];
NSString *idString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"id"];
NSString *titleString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"title"];
Also,
NSString *categoryString=dict[@"Category"];
NSString *idString=dict[@"id"];
NSString *titleString=dict[@"title"];
Check like this:
NSString *value=[[[getcate valueForKey:@"abcd"] objectAtIndex:0] valueForKey:@"category"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With