SBJson (aka json-framework)
JSON (JavaScript Object Notation) is a light-weight data interchange format that's easy to read and write for humans and computers alike. This library implements strict JSON parsing and generation in Objective-C.
Notable changes in 3.1
Automatic Reference Counting (ARC) Support
Version 3.1 requires Xcode 4.2 to build, because previous versions did not have ARC support. If you can't use Xcode 4.2, or for some reason can't use ARC, you need to stick with SBJson version 3.0.
New Features, Changes, and Notable Enhancements in 3.0
JSON Stream Support
We now support parsing of documents split into several NSData chunks, like those returned by NSURLConnection. This means you can start parsing a JSON document before it is fully downloaded. Depending how you configure the delegates you can chose to have the entire document delivered to your process when it's finished parsing, or delivered bit-by-bit as records on a particular level finishes downloading. For more details see SBJsonStreamParser and SBJsonStreamParserAdapter in the API docs.
There is also support for writing to JSON streams. This means you can write huge JSON documents to disk, or an HTTP destination, without having to hold the entire structure in memory. You can use this to generate a stream of tick data for a stock trading simulation, for example. For more information see SBJsonStreamWriter in the API docs.
Parse and write UTF8-encoded NSData
The internals of SBJsonParser and SBJsonWriter have been rewritten to be NSData based. It is no longer necessary to convert data returned by NSURLConnection into an NSString before feeding it to the parser. The old NSString-oriented API methods still exists, but now converts their inputs to NSData objects and delegates to the new methods.
Project renamed to SBJson
The project was renamed to avoid clashing with Apple's private JSON.framework. (And to make it easier to Google for.)
If you copy the classes into your project then all you need to update is to change the header inclusion from #import "JSON.h" to #import "SBJson.h".
If you link to the library rather than copy the classes you have to change the library you link to. On the Mac JSON.framework became SBJson.framework. On iOS libjson.a became libsbjson-ios.a. In both cases you now have to #import <SBJson/SBJson.h> in your code.
API documentation integrated with Xcode
The InstallDocumentation.sh script allows you to generate API documentation from the source and install it into Xcode, so it's always at your fingertips. (This script requires Doxygen to be installed.) After running the script from the top-level directory, open Xcode's documentation window and search for SBJson. (You might have to close and re-open Xcode for the changes to take effect.)
TweetStream Example Project
An example project showing how to use the new streaming functionality to interact with Twitter's multi-document streams. This also shows how to link to the iOS static lib rather than having to copy the classes into your project.
DisplayPretty Example Project
A small Mac example project showing how to link to an external JSON framework rather than copying the sources into your project. This is a fully functional (though simplistic) application that takes JSON input from a text field and presents it nicely formatted into another text field.
Features also present in previous versions
BSD license.
Super-simple high-level API: Calling -JSONValue on any NSString instance parses the JSON text in that string, and calling -JSONRepresentation on any NSArray or NSDictionary returns an NSString with the JSON representation of the object.
The SBJsonParser and SBJsonWriter classes provides an object-oriented API providing a good balance between simplicity and flexibility.
Configurable recursion depth limit for added security.
Supports (but does not require) garbage collection.
Sorted dictionary keys in JSON output.
Pretty-printing of JSON output.
Installation
The simplest way to start using JSON in your application is to copy all the source files (the contents of the Classes folder) into your own Xcode project.
In the Finder, navigate to the $PATH_TO_SBJSON/Classes folder and select all the files.
Drag-and-drop them into your Xcode project.
Tick the Copy items into destination group's folder option.
Use #import "SBJson.h" in your source files.
That should be it. Now create that Twitter client!
Upgrading
If you're upgrading from a previous version, make sure you're deleting the old SBJson classes first, moving all the files to Trash.
Linking rather than copying
Copying the SBJson classes into your project isn't the only way to use this framework. With Xcode 4's workspaces it has become much simpler to link to dependant projects. The examples in the distribution link to the iOS library and Mac framework, respectively. Des Hartman wrote a blog post with step-by-step instructions for iOS.
Links
GitHub project page
Example Projects
Online API docs
Frequently Asked Questions
分享到:
相关推荐
SBJSON包,一共有四种json解析的方式,这里只有一种。大家可以看看
SBJson 是 Objective-C 实现的一个 JSON 解析器和生成器.支持流, 格式友好的 JSON 输出 输出 JSON 的键是经过排序的 可配置的解析和输出的最大递归深度 纯 Objective-C. 无需第三方包依赖。
IOS中用于解析Json的工具类,JSONKit 的性能远优于JSON-Framework(即SBJSON)
ios下json数据解析的SBJson 库
SBJson 是 Objective-C 实现的一个 JSON 解析器和生成器,主要特性: 采用 New BSD 开源许可. 易用的 API 设计 支持流,详情请看 API docs 中的 SBJsonStreamParser 格式友好的 JSON 输出 输出 JSON 的键是经过排序...
SBJson 5 在Objective-C中基于块的JSON解析和生成。 总览 SBJson的第一大功能是基于流/块的操作。... SBJson通过以下方式将JSON类型映射到Objective-C类型: JSON类型 Objective-C类型 空值 NSNul
ios SBJson库解析json文件 解析使用
ios下三种解析json的库 sbjson TouchJson JSONKit 可直接使用
SBjson是一款json的解析软件,只许2句话,便可轻松解析
SBJson json的解析object c
JSON解析 SBJson的使用 里面注释很全
代码案例包括:touchJSon,JSONKIT,原生JSON,SBJSON
SBJson很简单, 幼稚的简短的json解析器。 入门指南 就像古老的中国谚语所说的那样,这是不打印文字的最好方法: 门生发大财! { " foo " : " bar " , " headers " : { " data " : [ 233 , { " readme " : " ...
sbjson 资源包,直接导人即可以使用
ios、Mac等开发必不可少的资源包。SBJson
第三方json解析,用于ios解析json字符串。常常用在网络下载的数据解析,使用简单便捷
json的使用,介绍,包括第三方json类库:jsonkit,sbjson,touchjson,同时包括json的pdf文档,还附加了gdataxml和json的代码练习说明
SBJSON的工具类
SBJsonParser 解析ios json 数据
跟网络上的有点不同,这里的是自己编写一个json 格式,然后利用sbjson解析出来,封装到对应的model实体,再通过tableview呈现出来,当中也涉及到了如何使用自定义cell,对于初学者学习json跟model实体和自定义cell...