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)