-1

Working with an iOS app managing data on a Parse-Server (/Heroku). I have the following issue when trying to save data.

Here is the code for the function where the problem happens:

func saveDataBlockOnline(_ dico: [String:String]) {
    let psvClassName = "Goodies",
    dataUnit=PFObject(className: psvClassName,
                      dictionary: dico)
    dataUnit.saveInBackground {
        (succeeded:Bool, error:Error?) in
        if succeeded {
            // Do something useful.
        } else {print("\(#function) Error:\(error ?? "" as! Error)")}
    }
}

Here is the error I get:

saveDataBlockOnline Error:Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

I guess I am getting some JSON answer that I don't use properly. So how should I modify the code?

There are other posts on the subject, but nothing that I found with a real solution.

A few more details may be useful:

The data saving on the server itself was working. But things started to go wrong when I added some cloud code, namely a Parse.Cloud.beforeSave to have a better control on how things are happening.

Michel
  • 10,303
  • 17
  • 82
  • 179

1 Answers1

0

The data you want to parse in not in correct format according to error message. Check your dictionary and Object(dataUnit) format