Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 需要目标c中的示例JSON解析器吗_Iphone_Objective C_Parsing_Json - Fatal编程技术网

Iphone 需要目标c中的示例JSON解析器吗

Iphone 需要目标c中的示例JSON解析器吗,iphone,objective-c,parsing,json,Iphone,Objective C,Parsing,Json,我想知道如何在objective C中解析json对象。我通过加载url获得了json对象。你能告诉我怎么做吗?有没有样品或参考资料 下面是示例json { "name":"WFNX", "now": { "id":"17749528", "song":"Back Down South", "artist":"Kings Of Leon" }, "desc":"101.7 - True Alternative", "audiostream":"h

我想知道如何在objective 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"
}

还有一些,请参见:


对于大型列表:


是一个很好的JSON参考网站。有一些网站,请参见:


对于大型列表:


是一个很好的JSON参考站点

在或上为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];

在或上签出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];

我使用的是YAJLiOS解析器,还不错,并且与ARC兼容,下面是文档

以及github上的解析器本身


如果您需要数组,请使用objectForKey方法或valueFoKey方法获取对象

我使用的是YAJLiOS解析器,不错,并且与ARC兼容,以下是文档

以及github上的解析器本身

如果您需要数组,可以使用objectForKey方法或valueFoKey方法获取对象

@rockey没有问题:)如果答案有用,您可以对其进行投票或选择它作为“接受答案”。祝你好运。@rockey没有问题:)如果答案有用,你可以投票表决或者选择它作为你的“接受答案”。祝你好运。你也可以参考这个链接。你也可以参考这个链接