Class

NSJSONSerialization

An object that converts between JSON and the equivalent Foundation objects.

Overview

You use the NSJSONSerialization 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:

Other rules may apply. Calling isValidJSONObject: or attempting a conversion are the definitive ways to tell if a given object can be converted to JSON data.

Topics

Creating a JSON Object

JSONObjectWithData:options:error:

Returns a Foundation object from given JSON data.

JSONObjectWithStream:options:error:

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

Creating JSON Data

dataWithJSONObject:options:error:

Returns JSON data from a Foundation object.

writeJSONObject:toStream:options:error:

Writes a given JSON object to a stream.

isValidJSONObject:

Returns a Boolean value that indicates whether a given object can be converted to JSON data.

Constants

NSJSONReadingOptions

Options used when creating Foundation objects from JSON data—see JSONObjectWithData:options:error: and JSONObjectWithStream:options:error:.

NSJSONWritingOptions

Options for writing JSON data.

Relationships

Inherits From

See Also

JSON

Using JSON with Custom Types

Demonstrates approaches for encoding and decoding different kinds of JSON in Swift.