I've seen the C++ JSON links on the official JSON site [1] and would like some feedback on which parser people prefer - for reliability, speed and ease of use.
I looked at most of them a year or so ago, and settled on JsonCpp (http://jsoncpp.sourceforge.net/). I've found it reliable, fast and easy to use, so 3/3.
I'm using JSON Spirit [1] on a project at the moment, I'm impressed with it so far.
Note that it does rely on Boost (if only for headers).
Handy features:
write_formatted
).Note that Objects are also implemented using vector [2] (not map), which means slower access, but it does mean that the order of elements is maintained.
[1] http://www.codeproject.com/KB/recipes/JSON_Spirit.aspxSee also Boost property_tree included in the 1.41.0 release of Boost:
http://www.boost.org/doc/libs/1_41_0/doc/html/property_tree.html [1]
Basically it provides a generic property tree structure and includes parses/generators for JSON, XML and INI. It is header only and it uses Boost Spirit for generation/parsing.
[1] http://www.boost.org/doc/libs/1%5F41%5F0/doc/html/property%5Ftree.htmlJansson - http://www.digip.org/jansson/
Just made my life easy.
I know you are asking about C++, but yajl [1] is definitely worth trying as well. It has many features that are not available from many other parsers, and most importantly, it's fast.
[1] http://lloyd.github.com/yajl/I just gave JSON Spirit (the header-only version) a try, because I was already using Boost in my project and JSON Spirit only depends on Boost.
However, I think the documentation (especially for the new header-only version) is not adequate at the moment. Maybe this will change.
jsoncpp builds, but it does not look like darwin-osx is a maintained platform. Even though scons might be an interesting build system the whole setup needs some love.
Tests passing on Snow Leopard 10.6 with
scons platform=linux-gcc
Try the UniversalContainer class. http://greatpanic.com/code.html. It provides a container that acts like a Php/Python/Perl variable that can be a hashmap, array, scalar, or whatever it needs to be. Additional routines allow the container to be serialized and deserialized to JSON.