Sunday, February 20, 2011

IPhone: Picking up a json objective-c library

As you read through this, please note the date of publishing [20-Feb-2011]. The content is going to be quite volatile in regard to time.
[Update – 27-Jan-2012, Starting with iOS5 you can use built-in NSJSONSerialization class,  example here: http://www.raywenderlich.com/5492/working-with-json-in-ios-5] 

Overcoming the temptation to use just a plist quasi "json" or xml format for storing my app user data, I went to see what json libraries would be readily available. Main driver for me here is the idea that I'm going to run into json API's in my app anyway, plus the "document" DB style aproach of NoSql databases will be sufficient for me for both on SQLite side and Google Datastore. So I'll keep some key data in SQLite with "blob" of json, and then will do the same on the datastore side.

What I found is:

json-framework, newly hosted at: http://stig.github.com/json-framework/
Quite actively developed, currently in v3 beta1, with stable version offered for download as 2.3.2. I found quite a few links with iphone json tutorials based on this framework. It was as well easy copy "Sources" directory to integrate into the app. Walk though the code showed its well structured and easy to understand manner and there are some tests in the project as well.

YAJL framework: https://github.com/gabriel/yajl-objc
Looks like last updated November 2010. Quite many files inside the project and author documented integration options talk more about binary library integration. I really want to see and play with the code myself, so not going further.

TouchJSON: https://github.com/TouchCode/TouchJSON
Looks like author is currently trying to reorganize the structure of his numerous projects, moved from google code to github and has made a few moves on github as well. Amount of code is bigger than in json-framework. Project is quite active and got quite a few tests inside as I can see, but I can't see as many tutorials and benefits actually. Not progressing.

JSONKit: https://github.com/johnezang/JSONKit
This is 1 m file + 1 h file long project. But there are no tests, so not progressing.


Here are some performance testing links I found interesting:

http://psionides.jogger.pl/2010/12/12/cocoa-json-parsing-libraries-part-2/
http://samsoff.es/posts/updated-iphone-json-benchmarks


Based on what I've read so far I'm not going to be disappointed with json-framework.

No comments: