Friday 1 March 2013

How to Parse JSON in Cocoa/Objective-C

The easiest method is to directly embed the source in your app as it’s pretty lightweight, and will work on both Mac and iPhone apps. Here is the instructions on how to use JSON in your app.

* Download the latest version of JSON framework.

* Drag the JSON folder into your project in Xcode. Check “Copy items into destination group’s folder (if needed)” when prompted.

*Once the source is embedded into your project, you need to import the framework to use it in your code.

#import "JSON.h"

Create a SBJsonParser object to parse JSON into a native Cocoa object. SBJsonParser will return either a NSDictionary or NSArray depending on the structure of the data. 

Sample for Parse the JSON URL in to your app.


Sample Code:-

here, In statuses, you will get all the JSON values, now, what values you want just take them separately using NSDictionary and Use. 

or

use this method also,

No comments:

Post a Comment