Reading Writing JSON
suggest changeSyntax
Swift 2 names are below. Swift 3 and later use JSONSerialization.jsonObject(with:options:) and JSONSerialization.data(withJSONObject:options:), with .prettyPrinted instead of NSJSONWritingOptions.PrettyPrinted.
- NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions) // Returns an object from jsonData. This method throws on failure.
- NSJSONSerialization.dataWithJSONObject(jsonObject, options: NSJSONWritingOptions) // Returns NSData from a JSON object. Pass NSJSONWritingOptions.PrettyPrinted for more readable output.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents