ios5嵌套json解析

LuZ*_*uZa 2 iphone parsing json ios5 nsjsonserialization

如何使用NSJSONSerialization转换此json?

{
   "messages":{
      "message":{
         "user":"value",
         "pass":"value",
         "url":"value"
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

Ind*_*ore 5

NSError* error;
NSDictionary *dit = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
if (!error) {
   //Get values from this dict using respective keys
   NSDictionary *msgs = [dict objectForKey:@"messages"];
   NSDictionary *msg = [msgs objectForKey:@"message"];
   NSString *user = [msg objectForKey:@"user"];
   NSString *pass = [msg objectForKey:@"pass"];
   NSString *url = [msg objectForKey:@"url"];
}
else {
   //Your error message
}
Run Code Online (Sandbox Code Playgroud)