Nsjsonserialization datawithjsonobjectoptionserror invalid top-level type in json write'

Hello everybody, recently the app is crashing often, here is a crash log. We use cookies for various purposes including analytics. You use the jsonserialization class to convert json to foundation objects and convert foundation objects to json a foundation object that may be converted to json must have the following properties. The data must be in one of the 5 supported encodings listed in the json specification.

Bascially the language doesnt know how your object should be represented in json which fields to include, how to represent references to other objects. Nsdata data nsjsonserialization datawithjsonobject. For example, when writing an app that provides search results for local. By continuing to use pastebin, you agree to our use of cookies as described in the cookies policy. Invalid toplevel type in json write stack overflow. The top level object is an nsarray or nsdictionary. Basically a couple of days ago my code worked fine, but after updating xcode i have been getting this invalid toplevel type in json write error. The top level object is an nsarray or nsdictionary all objects are instances of nsstring, nsnumber, nsarray, nsdictionary, or nsnull all dictionary keys are instances of nsstring. Invalid type in json write nsconcretemutabledata 0117 1. I have no idea how to fix this on my end but the crashing code is inside alamofire, specifically at.

To get a dictionary value from a json object type, conditionally cast it as string. If that option is not set, the most compact possible json will be generated. But im not able to serialize the json string into nsdata using nsjsonserialization, the json string is corrected and validated before, but when i use an nsstring from the string, it adds an extra pair of brackets json, which i can remove before trying the nsjsonserialization, here is how im trying to achive my goal. An object that may be converted to json must have the following properties. You should check whether the input will produce valid json before calling this method by using is valid jsonobject setting the nsjsonwriting pretty printed option will generate json with whitespace designed to make the output more readable. I cant say what is the error, because i tried here and worked. Asking for help, clarification, or responding to other answers. Jsonserialization foundation apple developer documentation. Getting invalid toplevel type in json write after updating xcode.

43 42 852 1043 1553 1227 1036 1439 1318 846 52 414 247 636 257 1598 1253 327 1578 40 942 1248 1061 781 991 1429 1283 715 1564 633 484 329 991 344 454 280 301 334 228 984 657 323 1081