
The JavaScript JSON Cookbook
By :

Objective-C's class libraries define the NSJSONSerialization
class, which can serialize to and from JSON. It converts JSON to NSDictionary
objects of values, with the keys, the names of the slots in the JSON, and the values of their JSON. It's available in iOS 5.0 and later.
Here's a simple example:
NSError* error; NSDictionary* data = [ NSJSONSerialization JSONObjectWithData: json options: kNilOptions error: &error ]; NSString* call = [ data ObjectForKey: @"call" ];
The NSJSONSerialization
class has a method, JSONObjectWithData:options:error
, that takes an NSString
, parsing options, and a place to record errors, and performs JSON parsing. It can accept JSON whose top level is an array or dictionary, returning an NSArray
or NSDictionary
result respectively. All values must be instances of NSString
, NSNumber
, NSArray
, NSDictionary
, or NSNull
respectively. If the top-level object is...
Change the font size
Change margin width
Change background colour