M.B
M.B

Reputation: 885

Issue to get json value

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

Answers (4)

simbesi.com
simbesi.com

Reputation: 1529

You can try like this..

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:0];

NSString *status = [[dictionary objectForKey:@"RN"] objectForKey:@"status"];

Upvotes: 1

manujmv
manujmv

Reputation: 6445

You can get this status with a single line code

NSString *status = [[dict objectForKey:@"RN"] objectForKey:@"status"];

Upvotes: 1

Satheesh
Satheesh

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

Pratyusha Terli
Pratyusha Terli

Reputation: 2343

NSDictionary *tmpDict = [yourDict objectForKey:@"RN"];
NSString *status = [tmpDict objectForKey:@"status"];

Upvotes: 1

Related Questions