[英]unable to parse json response from google
我试图从这个URL解析Json响应。 我使用过SBJsonParser,MTJSON和另一个解析器,但我在所有三种情况下都得到NULL。
apiUrlStr = @"http://maps.google.com/maps?output=dragdir&saddr=Delhi&daddr=Mumbai+to:hyderabad";
NSURL* apiUrl = [NSURL URLWithString:apiUrlStr];
NSString *apiResponse = [NSString stringWithContentsOfURL:apiUrl encoding:NSUTF8StringEncoding error:nil];
SBJsonParser *json = [[[SBJsonParser alloc] init] autorelease];
NSDictionary *dictionary = [json objectWithString:apiResponse];
NSLog(@"dictionary=%@", [json objectWithString:apiResponse]);
2011-12-09 16:59:01.226 MapWithRoutes [2523:207] dictionary =(null)
Plz建议我一些事情
如果选中了您使用JSONlint.com提供的URL并且JSON无效, 则为 Oke。 因此无法被任何库解析。
如果你使用了JSONkit,你可以提供一个带有parse调用的NSError
对象,看看出了什么问题:
NSError *error = nil;
NSDictionary *dictionary = [apiResponse objectFromJSONStringWithParseOptions:JKParseOptionNone error:&error];
if (!dictionary) {
NSLog(@"Error: %@", error);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.