我在我的iOS项目中解析Json。我得到以下字典。
{
RN = {
status = Fails;
};
}
现在我想获得关键状态。我如何从字典中获取它。请帮助。 感谢。
答案 0 :(得分:1)
NSDictionary *tmpDict = [yourDict objectForKey:@"RN"];
NSString *status = [tmpDict objectForKey:@"status"];
答案 1 :(得分:1)
试试这个,
NSError * jsonParsingError;
NSDictionary *yourJSONDict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError] //responseData is the JSON string.
NSString *status = [[yourJSONDict objectForKey:@"RN"] objectForKey:@"status"];
答案 2 :(得分:1)
您可以使用单行代码
获取此状态NSString *status = [[dict objectForKey:@"RN"] objectForKey:@"status"];
答案 3 :(得分:1)
你可以尝试这样..
NSMutableDictionary * dictionary = [[NSMutableDictionary alloc] initWithCapacity:0];
NSString * status = [[dictionary objectForKey:@“RN”] objectForKey:@“status”];