Reputation: 481
i am using json parsing in my application and this is my json data is as follow :
{"response" : {"success":false,"error": {"code":7,"description":"You are not logged in"}}}
and i want description means "You are not logged in" i my string so how can i do that please help me.....
Upvotes: 3
Views: 2877
Reputation: 2414
Check the blog post with sample code and step by step parsing of JSON.
http://pessoal.org/blog/2008/12/12/iphone-sdk-parsing-json-data/
http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/
Upvotes: 2
Reputation: 7559
We're using CJSONDeserializer (TouchJSON library) in the iPhone app being developed at work.
Just use the following method:
NSDictionary * dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:data error:&error];
where data is of type NSData *. It will convert the JSON string into a dictionary so you could get the value of description as follows:
[[[dictionary objectForKey:@"response"] objectForKey:@"error"] objectForKey:@"description"];
Upvotes: 2