I based my evaluation on following criteria,
1. Features and ease of use
2. Performance
3. Documentation and community support
As it is not practical to learn and evaluate all the available ones, I decided to try the most popular ones, which are,
1. json-cpp
2. CAJUN
3. json_spirit
4. libjson
1. json-cpp
Json-cpp is the most popular and widely used json library in c++. It has got a good feature set and nice interface, and is very easy to use. But I couldn't successfully integrate it on a 64-bit machine. I tried to get help on the forum but I didn't get any. Despite its popularity, the community is not very active. A lot of questions remains unanswered on the forum, even after long time. Also there are complaints from users like memory corruption, open critical bugs etc. Since I couldn't integrate it on 64-bit machine and I believe community is crucial for any open source project, I am dropping json-cpp from my further analysis.
2. CAJUN
Another popular one is Cajun. It's easy to build and integrate, with good interface and features. It comes with a small documentation and a sample program and should not be difficult to get started. But it is not being developed actively and there has been no release after 2009. Forum is also not active.
3. json_spirit
Json_spirti is another popular library with a long history. It has got good features and a nice interface. Building and integration was easy. But I noticed the source files take comparatively long time for compilation. It is written using boost spirit parser generator and hence there is a dependency over boost. The source package comes with example programs and one can start right away. This is being actively developed and the support is also good.
4. libjson
libjson is a super efficient, highly customizable json library with nice features. It provides both C style as well as C++ interface. It comes with some sample programs which would help one to get started in no time. Building and integration was easy. Customization can be done by editing a fully commented header file which should be very easy for any programmer. Another specialty is its well written and comprehensive documentation which is not very common with open source projects. libjson enjoys an active community and forum. The author is fully committed to the project and I was surprised by his quick response to any query in the forum or bug reports.
Performance benchmark
I wrote a small program to benchmark these libs. I measured the timings for two operations,
1. parsing - Parsing a json string into a library specific json object
2. writing - Converting the library specific json object into a json string
I have not done any customization of these libraries for extra performance enhancements. I have used an example json string available at www.json.org/example.html as test data. To get accurate results do the same test with your actual json data. I am doing this test on an Ubuntu Linux 64 bit machine with Intel Core i5 2.30 GHZ micro processor.
$ ./JsonBenchmarkCpp > results.dat
$ cat results.dat.
#library parsing writing
cajun 907 118
json_spirit 8655 510
libjson 81 115
Numbers are the time taken for an operation in micro seconds.
Results
I used gnuplot to draw a graph out of these numbers. As they say "A picture is worth a thousand words".
I had plot an enlarged graph to see the libjson timings!
This graph says it all. libjson is the clear winner, followed cajun and json_spirit. libjson can be customized further for higher performance.
Source code and the gnuplot script used for benchmarking can be found at https://github.com/lijoantony/JsonBenchmarkCpp. Feel free to fork away.
Conclusion
No software is perfect. Good ones undergo continuous evolution. A fully committed author and an active community gives and extra edge for libjson in this aspect. It has performed extremely well in my tests. So libjson is the winner in my analysis. I have chosen libjson for my project. However I would like to thank developers of all the libraries for their time and effort.
Update: 26-11-2011
I had built libjson with the default settings for the performance testing. By default libjson would not parse the json string completely and hence my numbers were wrong about libjson. So I did the test again with the proper setting and the post has been updated with the new numbers. Still libjson is at least 10 times faster than other libraries I had tested. Thanks to the libjson author who informed me about this mistake in my test.