views:

54

answers:

2

I want to know to parse a json object in objective c...

i get the json object by loading a url....

can u please tell me how to do it or any samples or any reference....

the following is the sample json...

{"name":"WFNX","now":
  {"id":"17749528","song":"Back Down South","artist":"Kings Of Leon"},
   "desc":"101.7 - True Alternative","audiostream":"http:\/\/www.streamaudio.com\/stations   \/asx\/wfnx_fm.asx","genre":"Rock","tz":"EST","id":"17880","yes":"station"
}
+4  A: 

There are a few out there, see:

http://code.google.com/p/json-framework/
http://github.com/schwa/TouchJSON

for a big list:

http://www.json.org/

is a great reference site for JSON

Mark
thanks Mark.. :]
rockey
+3  A: 

Checkout this JSON framework for Objective-C on code.google.com or on Github.

It is pretty straightforward to use. You instantiate your SBJSON object then call objectWithString with your buffer:

SBJSON * parser = [[SBJSON alloc] init];
NSString * buffer = @"{"name":"WFNX"}";
NSError* error = NULL;
// the type of json will depend on the JSON data in buffer, in this case, it will be 
// and NSDictionary with one key/value pair "name"->"WFNX"
id json = [parser objectWithString:buffer error:&error];
Cannonade
thanks Cannonade.. :)
rockey
@rockey no problems :) If the answer is useful you can upvote it or select it as your "accepted answer". Good luck.
Cannonade
hi cannonade..i used the TouchJson for parsing..i stored the parsed data in NSDictionary. but can i store the parsed data into my custom class object....i used the json object in the qustion above..
rockey