#671·rapidjson

More advanced JSON to custom structure examples

Author: wnewberyCreated Jun 28, 2016Updated Aug 26, 2026
Labelsexample

I want to parse some JSON structures into C++ objects, and am trying to determine the best approach. There is an example ( http://rapidjson.org/md_doc_sax.html#CustomDataStructure ) but that is only an extremely simple case and using a handcrafted enum like that quickly becomes very complex.

Using the DOM model, something along the lines of void read_json(const rapidjson::Value &val, SomeType *out) with various overloads and helpers is possible (and a write_json(writer,in) along similar lines), but would be very interested if anyone has already worked out such a design for the SAX handler API.