This JSON parser prototype was written as part of a proposal for the Boost C++ library for The Google Summer of Code 2013.
JSON parsing is a simple yet practical application of complier design. In this implementation we are parsing a subset of the JSON data types into a Tree API with a recursive descent parser.
The current implementation uses a Builder pattern to separate “code generation” from parsing. In our case, “code generation” is the creation of a data structure that reflects JSON arrays and objects and the assignment of JSON values into the data structure.
Representation of JSON data in C++ is an interesting challenge, we use the Dynamic C++ library to represent dynamically typed data. JSON arrays are represented by arrays, and objects are represented by hashmaps.
We are using the JSON scanner from the protoc library as a Lexer.
You can have an overview of the API by looking at the unit tests
A big thanks to Bjorn Reese for his mentoring and support during this prototype development.
Dependencies: Boost and Boost.Test. On Debian, this is provided by the packages libboost1.48-dev
and libboost-test1.48.0
The required parts of dynamic-cpp and protoc are included in the repository.
The Makefile is incomplete, you will need to create a bin/
and an obj/
folder in the project. Build has only been tested with g++ on a Linux environment. CMake is coming soon…
You can run the unit tests by typing bin/builder_test
and bin/parser_test