Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You want to serialize a dictionary or an array into a JSON object that you can transfer over the network or simply save to disk.
The dataWithJSONObject:options:error: method of
the NSJSONSerialization class can
serialize dictionaries and arrays that
contain only instances of NSString,
NSNumber, NSArray, NSDictionary variables, or NSNull for nil values. As mentioned, the
object that you pass to this method should either be an array or a
dictionary.
Now let’s go ahead and create a simple dictionary with a few keys and values: