需要在目标c中使用示例JSON解析器

roc*_*key 1 iphone parsing json objective-c

我想知道在目标C中解析一个json对象.我通过加载一个url获得了JSON对象.你可以告诉我怎么做或任何样品或任何参考.

以下是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"
}
Run Code Online (Sandbox Code Playgroud)

Red*_*ing 7

code.google.comGithub上查看Objective-C的这个JSON框架.

它非常简单易用.您实例化您的SBJSON对象,然后使用您的缓冲区调用objectWithString:

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];
Run Code Online (Sandbox Code Playgroud)


Mar*_*ark 5

有几个,见:

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

一个大清单:

http://www.json.org/

是一个很棒的JSON参考站点