0

我在我的 iOS 项目中解析 Json。我得到以下字典。

 {
   RN =     {
   status = Fails;
   };
 }

现在我想获得关键状态。我如何从字典中得到它。请帮忙。谢谢。

4

4 回答 4

1
NSDictionary *tmpDict = [yourDict objectForKey:@"RN"];
NSString *status = [tmpDict objectForKey:@"status"];
于 2013-11-06T05:45:51.140 回答
1

您可以使用单行代码获取此状态

NSString *status = [[dict objectForKey:@"RN"] objectForKey:@"status"];
于 2013-11-06T06:06:07.983 回答
1

尝试这个,

NSError * jsonParsingError;

NSDictionary *yourJSONDict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError] //responseData is the JSON string.

NSString *status = [[yourJSONDict objectForKey:@"RN"] objectForKey:@"status"];
于 2013-11-06T05:55:00.713 回答
1

你可以这样试试。。

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

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

于 2013-11-06T06:34:57.147 回答