JSON Libraries for iOS Comparison
I think is one of the most common questions for an iOS developer:
Which one is the best JSON library?
I think the best test that we can do is a quick benchmark, even if I think that it’s not only the speed that makes a library better than others.
So, today I decided to do a quick performance project to check which of the following libraries is the best one in terms of speed:
- SBJson - Previously known as json-framework
- NSJSONSerialization - Public API since iOS5
To do this quick test (at the moment I’m only deserializing the JSON file) I create a project with all the libraries.
I also created 3 different kind of JSON file:
- A JSON file from public Twitter timeline
- A random JSON file generated with 1000 records with variable objects *
- A classic JSON file with 100 records with 2 objects *
To generate the files marked with * I used this nice online tool: json-generator.appspot.com
For the test I used an iPhone 4S with iOS 5.0.1.
I’ll redo the test as soon as possible with an iPhone 4, iPhone 3GS and iPad 2.
This post has been updated with more accurate results!