Type Method


Returns a Foundation object from given JSON data.


class func jsonObject(with data: Data, options opt: JSONSerialization.ReadingOptions = []) throws -> Any



A data object containing JSON data.


Options for reading the JSON data and creating the Foundation objects.

For possible values, see JSONSerialization.ReadingOptions.

Return Value

A Foundation object from the JSON data in data, or nil if an error occurs.


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.

See Also

Creating a JSON Object

class func jsonObject(with: InputStream, options: JSONSerialization.ReadingOptions = [])

Returns a Foundation object from JSON data in a given stream.