Do not use Sbjson (json-framework)

Source: Internet
Author: User
Tags benchmark

Do not use Sbjson (json-framework)

Article Directory

I do not know why, in iOS development, many people use Sbjson (also known as json-framework) to do JSON parsing library. I think this is because Sbjson is the first JSON parsing library to appear on iOS. But with the popularity of iOS development, more and more excellent JSON parsing library has emerged, Sbjson and they compared to the performance of a large gap.

Now the main popular JSON parsing libraries in the iOS industry are:
Nsjsonserialization,
Apple JSON,
Touchjson,
Sbjson,
YAJL,
Jsonkit

These libraries have been benchmark tested by many peers in the industry. The test articles I searched for online include:

    • Https://github.com/samsoffes/json-benchmarks
    • http://blog.csdn.net/arthurchenjs/article/details/7009995
    • http://blog.csdn.net/ccat/article/details/7207871
    • http://omegadelta.net/2011/11/04/json-framework-now-sbjson-is-evil/
    • Http://stackoverflow.com/questions/2256625/comparison-of-json-parser-for-objective-c-json-framework-yajl-touchjson-etc

is one of the benchmark test results graphs that I intercepted from Arthurchenjs's blog post (the shorter the bar, the faster the resolution):

As you can see from these articles, Sbjson in most tests is the first or penultimate position in the countdown. So, Sbjson actually in the performance of this point, is really very "SB", it is not worth a souvenir. Quickly change your JSON parsing library to something else!

So which one should I switch to?
If your app only supports iOS 5.0 and above, use the official Apple-provided JSON library directly: nsjsonserialization
Library.
If your app to support iOS 5.0 below the system, then I personally recommend Jsonkit, but Jsonkit itself do a lot of memory optimization, so does not support arc, you can use it with the-fno-objc-arc of the compilation flag, The detailed steps for setting up this build flag can be found in this article.

The use of Jsonkit is also very convenient, in use only need to Sbjson Jsonvalue method replaced Objectfromjsondata,jsonrepresentation method for jsonstring can. Attach an example of use:

"JSONKit.h"

NSString *path = [[nsbundle Mainbundle] Pathforresource:@ "Data" OfType:@ "JSON"];
NSData *content = [nsdata Datawithcontentsoffile:path];
Nsdictionary *kitdata = [content objectfromjsondata];
NSString *kitstring = [Kitdata JSOnstring];

I hope you have a good time.

Do not use Sbjson (json-framework)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.