Announcing JSONKit - http://github.com/johnezang/JSONKit A BSD Licensed JSON serializer / deserializer.
Yes, yet another JSON library for Cocoa / Objective-C. Why another JSON library? Well, if you assume that all the JSON libraries offer similar functionality, that leaves one major metric that you can improve on: Speed. And that's the metric JSONKit is aimed at. As an example, using the Sam Soffes JSON benchmarks ( http://samsoff.es/posts/updated-iphone-json-benchmarks , http://github.com/samsoffes/json-benchmarks), I get the following results when running on the iPhone simulator: [Session started at 2010-07-30 08:57:06 -0400.] *2010-07-30 08:57:08.431 JSONBenchmarks[754:207] Starting benchmarks with 100 iterations for each library* *2010-07-30 08:57:09.257 JSONBenchmarks[754:207] TouchJSON average read time : 0.003940* *2010-07-30 08:57:10.344 JSONBenchmarks[754:207] TouchJSON average write time : 0.009265* *2010-07-30 08:57:10.967 JSONBenchmarks[754:207] JSON Framework average read time : 0.002701* *2010-07-30 08:57:11.182 JSONBenchmarks[754:207] JSON Framework average write time: 0.002077* *2010-07-30 08:57:11.709 JSONBenchmarks[754:207] YAJL average read time : 0.001834* *2010-07-30 08:57:11.997 JSONBenchmarks[754:207] YAJL average write time : 0.002652* *2010-07-30 08:57:12.508 JSONBenchmarks[754:207] Apple JSON average read time : 0.001746* *2010-07-30 08:57:12.713 JSONBenchmarks[754:207] Apple JSON average write time : 0.001975* *2010-07-30 08:57:13.109 JSONBenchmarks[754:207] JSONKit average read time : 0.000591* *2010-07-30 08:57:13.157 JSONBenchmarks[754:207] JSONKit average write time : 0.000460* *2010-07-30 08:57:13.157 JSONBenchmarks[754:207] Done. Quitting...* * * JSONKit manages to turn in some pretty impressive times relative to the other solutions. Benchmarks should always be taken with a grain of salt, but I'm fairly confident that JSONKit will beat the current crop of Objective-C JSON solutions out there. If you're going to do some benchmarking of your own, I'd recommend using "-O3 -DNS_BLOCK_ASSERTIONS" for maximum performance. One of the ways that JSONKit manages to improve "read" (i.e., deserialize UTF8 JSON text in to Objective-C objects) times is by keeping a small cache of recent object conversions. This is particularly effective for JSON key / value dictionaries where the keys tend to repeat. Another advantage of using a cache is that it reduces the amount of memory required for the final Objective-C representation of the serialized JSON because an object is instantiated only once and reused again and again. Now, despite the obvious improvements in speed, there are some drawbacks: - JSONKit is new. Brand new. Days old as of this writing. This means there's almost certainly bugs. While I've done my best at ad-hoc testing, I've yet to crank out a comprehensive unit test harness for it. - There's no documentation, so you're pretty much on your own. While I'm capable of writing high quality documentation (see RegexKitLite, for example), writing high quality documentation takes a long time to write, usually 2-4 times longer than writing the code itself. - The API is pretty basic. Actually, this is a bit of an understatement. This reflects the current state of development which is focused more on the internals than making use of its functionality. :) Feedback in this are is appreciated. - The guts are crufty C. Very crufty C. This reflects the primary objective: speed. The idea is to provide a quality, very fast primitive that can be used from the comfort of Objective-C. All the gory details are hidden away. Normally I wouldn't recommend this kind of optimization to anyone, but there are exceptions to every rule. I think there is a large enough need for a JSON primitive that the extra effort is worth it in this case. - No support for garbage collection, and I doubt there ever will be. Whether or not JSONKit continues on depends on the level of interest from the community. Even if JSONKit "dies", it raises the bar in terms of performance. A little competition can go a long way and hopefully this will encourage the other JSON solutions out there to meet or beat the performance of JSONKit. To that end, I openly encourage the authors of other JSON solutions to study JSONKit and borrow anything from JSONKit that can improve their solution. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com