Learning JsonCpp: a C++ JSON parser tutorial
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.
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.
If you aren’t a fan of C++, I’ve also written a Perl6 tutorial on parsing JSON.