Update (29 July 2013): I tagged v1.0.0 of the code on github. It loads and saves a JSON file properly. I ran into a weird issue with iterators but I think that’s my own fault for not completely understanding how to reference/dereference them. In any case, I think this is a good enough experiment to work with and start using JsonCpp in DeskNewsBlur.
I’m coding up a desktop client for NewsBlur and decided to figure out how to use the JsonCpp library first. I need it for parsing JSON from NewsBlur’s REST API, deserializing it into news feeds and news feed items.
I’m using WxWidgets for the desktop client and wanted to focus on one thing at a time. The other issue I’m having is that JsonCpp doesn’t seem to be packaged up for distribution on Ubuntu or other distros. I think I’m going to end up statically linking in JsonCpp and WxWidgets…Click here to check out a good book on using wxWidgets for cross-platform GUI programming.
JsonCpp isn’t too bad to work with, but the API docs need more of a tutorial. I hope that my code in learning-jsoncpp can serve as kind of a tutorial.
Here’s a sample of the JSON-specific code:
2017 UPDATE: JsonCpp is a good solid C++ library to work with and I hope the above code sample has given you a nice way to work with C++ and JSON files. What’s interesting about JSONCPP is that even Google uses it in their C++ library for their Data Layer API. Another cool thing about JsonCpp is that it gives you the ability to open JSON configuration files for all those Node.js files, meaning you can re-use configs and build a faster more performant project out of a frontend web development project.