-1

I am implementing SBJSON to fetch the data from web service. My code in "ConnectionDidFinishLoading" is as follows:

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);

But I got the error msg in my console as follows:

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

I have referred several links on stackoverflow and I also use google to find the answer but I am not able to get the solution

If you have solution then share it with me.

Thanx in advance...

K.P.
  • 324
  • 4
  • 13
  • 2
    what is your response string? **NSLog(@"Response String %@", responseString);** post its output. And also verify your json string at http://jsonlint.com/. – Devang Apr 18 '12 at 04:49
  • Refer to this link: http://stackoverflow.com/questions/5739878/jsonvalue-failed-error-while-fetching-data-from-server-into-iphone. – Parth Bhatt Apr 18 '12 at 08:42

2 Answers2

0

first u have to call the selector.

         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];

than

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

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

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

         NSLog(@"%@",parseDict);

     }
freelancer
  • 1,658
  • 1
  • 16
  • 37
0

I just had this problem and it turned out to be that the permissions on the directory used by the web service had been changed.

So browse to the WS or try another means of accessing it to make sure it's up.

SteveCav
  • 6,649
  • 1
  • 50
  • 52