http://blog.objectgraph.com/index.php/2010/02/24/how-to-use-touch-json-and-sbjson/
http://stackoverflow.com/questions/286087/best-json-library-to-use-when-developing-an-iphone-application
I will show how to use each of these libraries to decode JSON code in this post.
Touch JSON:
Include the following in your header
#import "CJSONDeserializer.h"
NSString *twitterTrendsUrl=@"http://search.twitter.com/trends.json";
NSData *flickrData=
[NSData dataWithContentsOfURL:[NSURL URLWithString:twitterTrendsUrl]];
NSError *theError = nil;
id theObject =
[[CJSONDeserializer deserializer] deserialize:flickrData error:&theError];
NSLog(@"Error: %@", theError);
NSLog(@"Result: %@", theObject);
SB JSON:
The thing i like about SBJSON is it adds functions directly into NSString to get NSDictionary or NSArray objects when deserializing JSON strings.
Start with including the following header
#import "JSON.h"
Then you can simply use the following code
NSString *twitterTrendsUrl=@"http://search.twitter.com/trends.json";
NSString *output=
[NSString stringWithContentsOfURL:[NSURL URLWithString:twitterTrendsUrl]];
id theObject= [output JSONValue];
NSLog(@"%@",theObject);
Please remember stringWithContentsOfURL has been deprecated so I would not recommend using it. We also just include the entire source of the specific JSON library when building our apps.
分享到:
相关推荐
ios下json数据解析的SBJson 库
SBJSON包,一共有四种json解析的方式,这里只有一种。大家可以看看
ios下三种解析json的库 sbjson TouchJson JSONKit 可直接使用
JSON解析 SBJson的使用 里面注释很全
ios SBJson库解析json文件 解析使用
SBJson 5 在Objective-C中基于块的JSON解析和生成。 总览 SBJson的第一大功能是基于流/块的操作。... SBJson通过以下方式将JSON类型映射到Objective-C类型: JSON类型 Objective-C类型 空值 NSNul
SBjson是一款json的解析软件,只许2句话,便可轻松解析
SBJson 是 Objective-C 实现的一个 JSON 解析器和生成器.支持流, 格式友好的 JSON 输出 输出 JSON 的键是经过排序的 可配置的解析和输出的最大递归深度 纯 Objective-C. 无需第三方包依赖。
代码案例包括:touchJSon,JSONKIT,原生JSON,SBJSON
SBJson json的解析object c
sbjson 资源包,直接导人即可以使用
SBJson很简单, 幼稚的简短的json解析器。 入门指南 就像古老的中国谚语所说的那样,这是不打印文字的最好方法: 门生发大财! { " foo " : " bar " , " headers " : { " data " : [ 233 , { " readme " : " ...
ios、Mac等开发必不可少的资源包。SBJson
第三方json解析,用于ios解析json字符串。常常用在网络下载的数据解析,使用简单便捷
SBJson 是 Objective-C 实现的一个 JSON 解析器和生成器,主要特性: 采用 New BSD 开源许可. 易用的 API 设计 支持流,详情请看 API docs 中的 SBJsonStreamParser 格式友好的 JSON 输出 输出 JSON 的键是经过排序...
SBJSON的工具类
SBJsonParser 解析ios json 数据
json的使用,介绍,包括第三方json类库:jsonkit,sbjson,touchjson,同时包括json的pdf文档,还附加了gdataxml和json的代码练习说明
跟网络上的有点不同,这里的是自己编写一个json 格式,然后利用sbjson解析出来,封装到对应的model实体,再通过tableview呈现出来,当中也涉及到了如何使用自定义cell,对于初学者学习json跟model实体和自定义cell...
SBJson 3.1 与之前版本的不同是3.1支持ARC 更加适合Xcode 4.2版本及以上版本 在使用的时候将classes文件夹拖入项目,然后在想要使用SBJson的文件中 #import "SBJson.h"即可