Browsing articles tagged with " NSJSONSerialization"
Nov
21
2011

JSON in ios 5

json_file

Before ios 5, we have to use third party JSON library like SBJSON or TouchJson to deal with JSON data. Today, iOS 5 has built-in APIs in the Foundation Framework which is called the NSJSONSerialization to make it easy to read and write JSON. Click here for reference. Below is an example of how to read JSON data into NSArray, NSDictionary and NSString. NSString* str= @"{\"name\":\"cayden\",\"hobby\":[{\"0\":\"programming\"}, {\"1\":\"gym\"}]}"; NSData* data=[str dataUsingEncoding:NSASCIIStringEncoding];   NSError* error; NSDictionary* json [...]

Ads

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Facebook Page

Categories