php - json parsing failed - cocoa error 3840 and invalid value around character 0

Solution:
Updated answer:
I think now that you have posted the Objective-C code that uses this received JSON, it becomes clear what the actual problem is.
It sounds to me that you are using Core Data (PersonStore
) to persist your incoming data.
If you are making Core Data calls from the same thread thatconnectionDidFinishLoading:
is being called on, you are most likely running into a threading issue where Core Data is not happy that you call it from a thread other than the main thread.
Give this a try: in yourconnectionDidFinishLoading:
wrap your code in the following:
dispatch_async(dispatch_get_main_queue(), ^{
// Include the code here that walks over the incoming JSON
// and creates new `Person` instances.
});
This will execute everything in that block, on the main thread. Which is generally a good idea for Core Data usage. (Probably even required, check the documentation, there is a special section on Core Data & Threads if I remember correctly).
Very curious if this does the trick.
Old answer:
The output ofvardump
is not actually valid JSON. You need to use thejson_encode()
function instead.
You can turn theNSData
that you received from the server into a string by doing something like this:
if let s = String(data: data, encoding: NSUTF8StringEncoding) {
println(s)
}
You did not mention if you work in Swift or Objective-C but the above translates easily to Objective-C.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: your lock file does not contain a compatible set of packages. please run composer update
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.