Skip to content

Instantly share code, notes, and snippets.

@ArchieR7
Created September 19, 2017 21:18
Show Gist options
  • Save ArchieR7/4c0bd048a15884a4e6bf26c440622100 to your computer and use it in GitHub Desktop.
Save ArchieR7/4c0bd048a15884a4e6bf26c440622100 to your computer and use it in GitHub Desktop.
/* Create a Foundation object from JSON data. Set the NSJSONReadingAllowFragments option if the parser should allow top-level objects that are not an NSArray or NSDictionary. Setting the NSJSONReadingMutableContainers option will make the parser generate mutable NSArrays and NSDictionaries. Setting the NSJSONReadingMutableLeaves option will make the parser generate mutable NSString objects. If an error occurs during the parse, then the error parameter will be set and the result will be nil.
The data must be in one of the 5 supported encodings listed in the JSON specification: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. The data may or may not have a BOM. The most efficient encoding to use for parsing is UTF-8, so if you have a choice in encoding the data passed to this method, use UTF-8.
*/
open class func jsonObject(with data: Data, options opt: JSONSerialization.ReadingOptions = []) throws -> Any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment