-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
The JavaScript JSON Cookbook
By :
You can also use the NSJSONSerializer class to serialize NSDictionary or NSArray; simply use the dataWithJSONObject method.
Here's a simple example assuming that data is NSDictionary you want to convert to JSON:
NSError *error; NSData* jsonData = [NSJSONSerialization dataWithJSONObject: data options: NSJSONWritingPrettyPrinted error: &error];
The dataWithJSONObject:options:error method can take NSArray or NSDictionary and returns an NSData blob with the encoded JSON of the collection you passed. If you pass kNilOptions, the JSON will be encoded in a compact manner; for pretty-printed JSON, pass the option NSJSONWritingPrettyPrinted instead.
Apple's documentation for the NSJSONSerialization class is at https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSJSONSerialization_Class/index.html.
Change the font size
Change margin width
Change background colour