繁体   English   中英

iPhone中解析JSON响应时出现问题

[英]problem in parsing JSON response in iphone

我正在从此链接获取json数据

现在我要从“ html_instructions”中获取数据:part

NSDictionary *result = [stringtext JSONValue];
NSLog(@"here");
NSArray *resultarr = [result objectForKey:@"routes"];
NSString *string;

for(NSDictionary *di in resultarr){
    NSLog(@"for loop");
    string = [[di objectForKey:@"legs"] objectForKey:@"steps"];
}

但是在控制台中打印“ for loop”后,它将引发异常

2011-05-20 16:16:26.997 speedymap[759:207] -[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x62a7d60

2011-05-20 16:16:26.999 speedymap[759:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x62a7d60'

请帮我,我想要html_instructiuons字段值

检查resultarrdi真的包含任何东西。

NSDictionary *result = [stringtext JSONValue];
NSLog(@"here");
NSArray *resultarr = [result objectForKey:@"routes"];
CFShow(resultarr);
NSString *string;

for(NSDictionary *di in resultarr){
    CFShow(di);
    NSLog(@"for loop");
    NSArray *tempArr = [[di objectForKey:@"legs"] objectForKey:@"steps"];
}

http://jsonviewer.stack.hu/#http://maps.googleapis.com/maps/api/directions/json?origin=delhi&destination=noida&waypoints=&sensor=true

检查查看器并相应地设置值。 [di objectForKey:@“ legs”]返回一个数组。 该数组的第一个对象是具有关键步骤的字典。 但这也返回另一个数组。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM