2011-12-09 2 views
0

This URL에서 Json 응답을 구문 분석하려고합니다. SBJsonParser, MTJSON 및 다른 파서를 사용했지만 세 가지 경우 모두 NULL이 표시됩니다. 59 : 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

01.226 MapWithRoutes [2523 : 207] 사전 = (null가)

Plz은이

+0

귀하의 게시물 핵심 부품의 알을 많이 누락되었습니다 :

당신이 무엇이 잘못되었는지 볼 수는 구문 분석 호출과 함께 NSError 객체를 제공 할 수 JSONkit를 사용한 경우 http://mattgemmell.com/2008/ 12/08/what-have-you-tried/ – rckoenes

+0

@rckoenes, 나는 그것이 아무것도없는 것 같지 않습니다. JSON은 어쨌든 디코딩하지 못합니다. –

+0

그게 내가 말하는거야. 나는 지금 무엇을해야한다고 생각 하느냐? –

답변

2

해두는 URL을 확인하면 나에게 무언가를 제안한다 JSONlint.com으로 제공되며 JSON이 유효하지 않습니다. 따라서 어떤 라이브러리에서도 파싱 할 수 없습니다.

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 객체의 키에 문자열 따옴표가 없습니다. –

관련 문제