2012-04-18 2 views
-1

웹 서비스에서 데이터를 가져 오기 위해 SBJSON을 구현 중입니다.오류 : JSON 인식 할 수없는 선행 문자

NSString *responseString = [[NSString alloc] initWithData:responseData encoding: NSUTF8StringEncoding]; 

    NSLog(@"Response String %@", responseString); 

    NSDictionary *results = [responseString JSONValue]; 

    NSString *extractUsers = [results objectForKey:@"d"]; 
    NSDictionary *finalResult = [extractUsers JSONValue]; 
    NSLog(@"Final Results : %@",finalResult); 

을하지만, 다음과 같이 내 콘솔에서 오류 MSG를 가지고 : I에 유래에 여러 링크를 언급하고 나는 또한에 구글을 사용

-JSONValue failed. Error trace is: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x686d010 {NSLocalizedDescription=Unrecognised leading character}")

다음과 같이 "ConnectionDidFinishLoading"나의 코드는 대답을 찾을 수 있지만 해결책을 얻을 수 없습니다.

해결책이 있다면 나에게 알려주십시오.

고맙습니다 ...

+2

응답 문자열은 무엇입니까? ** NSLog (@ "응답 문자열 % @", responseString); ** 출력을 게시합니다. 또한 json 문자열을 http://jsonlint.com/에서 확인하십시오. – Devang

+0

브라우저에서 URL을 확인하십시오. – Ayaz

+0

다음 링크를 참조하십시오 : http://stackoverflow.com/questions/5739878/jsonvalue-failed-error-while-fetching-data-from-server-into-iphone. –

답변

0

먼저 선택기를 호출해야합니다.

  DownloadManager *mgr= [[DownloadManager alloc] sharedManager:self:@selector(downloadVideos:)];// initialize your class where u write all the methods 

       [mgr downloadVideos]; // call method where u send request to particular url 
     [mgr autorelease]; 

-(void)downloadVideos:(NSMutableData*)data{ 

      NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 

     NSDictionary *parseDict = (NSDictionary*)[responseString JSONValue]; 

     NSLog(@"%@",parseDict); 

    } 
0

보다 난 그냥이 문제를 가지고 있으며 웹 서비스에서 사용하는 디렉터리에 대한 권한이 변경되었다고 밝혀졌다.

그래서 WS로 찾아 보거나 다른 방법으로 접속 해보십시오.