Reputation: 885
I am parsing Json in my iOS project.I am getting the following dictionary.
{
RN = {
status = Fails;
};
}
now I want to get key status. How i get it from dictionary.Please help. Thanks.
Upvotes: 0
Views: 82
Reputation: 1529
You can try like this..
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:0];
NSString *status = [[dictionary objectForKey:@"RN"] objectForKey:@"status"];
Upvotes: 1
Reputation: 6445
You can get this status with a single line code
NSString *status = [[dict objectForKey:@"RN"] objectForKey:@"status"];
Upvotes: 1
Reputation: 11276
Try this,
NSError * jsonParsingError;
NSDictionary *yourJSONDict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError] //responseData is the JSON string.
NSString *status = [[yourJSONDict objectForKey:@"RN"] objectForKey:@"status"];
Upvotes: 1
Reputation: 2343
NSDictionary *tmpDict = [yourDict objectForKey:@"RN"];
NSString *status = [tmpDict objectForKey:@"status"];
Upvotes: 1