[英]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.