1

I have used link code for send and get json data.

I modified the code for sync data with the web server using following code.

- (IBAction)syncTickets:(id)sender {

 [self postTest];
 [self getTest];

}

I have override getTest function to save data into the phone database. I got an error:

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.
(Cocoa error 3840.)" (JSON text did not start with array or object and option to allow 
fragments not set.) UserInfo=0x987b960 {NSDebugDescription=JSON text did not start
with array or object and option to allow fragments not set.
}

It only happens when I am syncing for the first time afterwards it works fine.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Susitha
  • 3,339
  • 5
  • 27
  • 41

1 Answers1

3

I have already given answer here,

The same answer as above

It may possible that, the response from your server doesn't contain valid JSON.

Technically, The JSON object must be start with either an "array" or an "object (dictionary)".

So, Whatever your server is returning isn't.

And, you can force the JSON to be consumed regardless by using the NSJSONReadingAllowFragments option.

by using ,

AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];
Community
  • 1
  • 1
Vandit Mehta
  • 2,572
  • 26
  • 41