Parsing JSON with NSJSONSerialization
Turn API responses into usable Objective-C objects with NSJSONSerialization, and safely navigate the resulting dictionaries and arrays.
JSON Meets Objective-C
Most APIs return JSON. Objective-C parses it with the Foundation class NSJSONSerialization, mapping JSON to native objects you already know.
The Type Mapping
JSON maps to Foundation types:
- object ->
NSDictionary - array ->
NSArray - string ->
NSString - number/bool ->
NSNumber - null ->
NSNull
All lessons in this course
- NSURLSession for API Calls
- Grand Central Dispatch (GCD)
- NSOperationQueue for Complex Tasks
- Parsing JSON with NSJSONSerialization