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.

1 Answer 1

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];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.