You use the
NSJSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON.
- iOS 5.0+
- macOS 10.7+
- tvOS 5.0+
- watchOS 2.0+
An object that may be converted to JSON must have the following properties:
All dictionary keys are instances of
Numbers are not NaN or infinity.
Other rules may apply. Calling
is or attempting a conversion are the definitive ways to tell if a given object can be converted to JSON data.