Search code examples
iphonejsonjson-frameworkjsonkit

Which json library to use on iphone to consume gson/jackson generated json


I need to build a java based JSON data API that will be accessed from mobile devices: Android, Iphone... I have narrowed down to these:

  • Server side data api - gson/jackson lib (pojo to json)
  • Android side - gson/jackson lib (json to pojo)
  • Iphone side - I googled & found that there are a bunch of frameworks Jsonkit, json-framework, touch json etc etc.

Question:

  • Can someone make a recommendation on the iphone side json library? The gson/jackson generated json output of the data api, must be consumable from iphone without any special tweaks to json structure

  • Is there any java Collection type that I should stay away from(on server side) to ensure the json is directly convertible to objective c objects?

  • Any other gotchas?

Note: I am aware of PhoneGap, titanuim & some equivalents - but not interested in them. Json is meant to be a universal format, but I have had cross-library issues earlier - hence this attempt to understand from people with prior experiance on the subject

Thanks!


Solution

    • I've been using RestKit Library in an iPhone App Project. It is a nice framework that supports HTTP request/response handling with (mostly REST) servers, JSON/XML parsers to help you with data translation and a JSON <-> Object Mapping system.

      It may supply your iPhone server communication needs (making requests to the server and receiving JSON responses from server and converting each of them into objective-c objects).

    • For RestKit, it only matters the objects of your JSON file. So you are free to use any class or collection in your server as far as you generate a valid JSON file as response.

    • It took me some time to learn how to use RestKit properly in my applications. But when you get used to it, it definitely saves you time, because it hides you the complexity of parsing JSON files for every request made to server. You are right in trying to pick a good JSON data handling API for your application.

      Another good thing about RestKit is its community. It has a GitHub, a Google Groups and an IRC channel. If you plan to use it as a framework, assigning to its mailing list is definitely a good idea.

    Have a nice coding! ;P