Comparison of JSON Parser for Objective-C (JSON Framework, YAJL, TouchJSON, etc)

IphoneObjective CJson

Iphone Problem Overview


As far as I know, there are three JSON Parsers for Objective-C, JSON Framework, YAJL, and Touch JSON. Then, These three would have their own characteristics.

For example:
YAJL can be used as a SAX style parser.
JSON Framework has relatively long history and is widely used.
Touch JSON parses NSData instead of NSString.

In addition, as far as I tested, the result of performance comparison is as follows:
[fast] YAJL > JSON Framework > Touch JSON [slow].

If you know pros and cons of these JSON parsers, could you tell me?
Lastly, if you know any other JSON Parser, please tell me.

Iphone Solutions


Solution 1 - Iphone

If you're looking for speed, take a look at JSONKit. It is (usually) much faster than the already mentioned JSON libraries, often an order of magnitude faster. And because of it's "recently instantiated object cache", it will (again, usually) use less memory as well.

Solution 2 - Iphone

Considering a comparison that I did, the fastest library is JSONKit, followed by NSJSONSerialization (now public API) and NextiveJSON. SBJSON and TouchJSON are a little bit slower than the previous 3 libraries.

The comparison has been done using an iPhone 4S with iOS 5.0.1.

Solution 3 - Iphone

There's also this parser:

I don't remember how I stumbled upon this one, but it looked lightweight and simple, so I thought that it suits my needs. I event forked it in order to add initialization from NSData. As I needed to parse small responses, I didn't care about the performance. It would be interesting to know how it performs though.

Solution 4 - Iphone

I think JSONKit is faster than YAJL and YAJL is faster than Touch JSON and IOS5 class NSJSONSerialization class is much faster. NSJSONSerialization have no need to use any third party APIs.

Solution 5 - Iphone

Look at this post. <30 characters>

Solution 6 - Iphone

Why not have a look at akosma's benchmarks on parsers where he compares different kinds of parsers. If one parser is missing, you might as well add it to the tests, since his code is open source.

iPhoneWebServicesClient

Solution 7 - Iphone

If you are looking for a serializer from NSObject to JSON and vice versa, you might want to checkout OBJC JSONSerializer

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontomuteView Question on Stackoverflow
Solution 1 - IphonejohneView Answer on Stackoverflow
Solution 2 - IphonebontoJRView Answer on Stackoverflow
Solution 3 - IphoneRomanView Answer on Stackoverflow
Solution 4 - IphoneArvindView Answer on Stackoverflow
Solution 5 - IphoneberecView Answer on Stackoverflow
Solution 6 - IphonecodeclashView Answer on Stackoverflow
Solution 7 - IphoneMahadevan SreenivasanView Answer on Stackoverflow