2011-12-09 10 views
0

私はThis URLからJson応答を解析しようとしています。私はSBJsonParser、MTJSONと別のパーサを使用していますが、私は3つのケースすべてでNULLを取得しています。Googleからのjson応答を解析できません

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]辞書=(ヌル)

PlzはURLあなたをチェックすると私に何か

+0

あなたの投稿は要部のアルロットが欠落しています。http://mattgemmell.com/2008/ 12/08/what-have-you-tried/ – rckoenes

+0

@rckoenes、私は何かが欠けているとは思わない。とにかくJSONのデコードに失敗します。 –

+0

私は何を言っています。私は今何をすると思いますか? –

答えて

2

オケを提案JSONlint.comとし、JSONは無効です。したがって、どのライブラリでも解析できません。

あなたがJSONkitを使用した場合は、何が悪かったのか確認するために解析コールでNSErrorオブジェクトを供給することができます:

NSError *error = nil; 
NSDictionary *dictionary = [apiResponse objectFromJSONStringWithParseOptions:JKParseOptionNone error:&error]; 

if (!dictionary) { 
    NSLog(@"Error: %@", error); 
} 
+0

行1の解析エラー: {tooltipHtml: "(2,13 -----^ 'STRING'、 '}'を入力する –

+0

http://jsonviewer.stack.hu/で作業しています –

+0

ああ、tooltipHtmlのようなJSONオブジェクトのキーには文字列の引用符がありません。 –

関連する問題