A single-header C++ library for parsing JSON directly to C++ structs and serializing structs back to JSON.
json_struct is a single-header C++ library that automatically parses JSON data into C++ structs and serializes structs back to JSON. It solves the problem of manual JSON handling in C++ by providing direct mapping between JSON and native C++ objects, reducing boilerplate code and potential errors.
C++ developers working with JSON configuration files, APIs, or data formats who want a lightweight, dependency-free solution for object serialization and deserialization.
Developers choose json_struct for its simplicity, zero-dependency header-only design, and support for relaxed JSON parsing—making it ideal for human-editable configuration files while maintaining full compatibility with standard JSON.
json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Integration is trivial—just copy json_struct.h into your project, avoiding build system headaches, as emphasized in the README's 'Getting Started' section.
Enables non-standard JSON features like comments and unquoted keys, making it ideal for human-editable config files, demonstrated in the relaxed parsing examples.
Automatically binds JSON to C++ structs with minimal macros like JS_OBJ, eliminating manual parsing boilerplate for common use cases.
JS::Map allows runtime inspection and type dispatch for variable JSON structures, as shown in the vehicle type handling example.
Every struct must be annotated with JS_OBJ or similar macros, which can clutter code and isn't compatible with all design patterns or legacy codebases.
Error checking is verbose, requiring explicit checks of ParseContext.error after each operation, increasing code complexity, as seen in the dynamic JSON example.
Lacks built-in JSON Schema validation or advanced data integrity checks, forcing developers to implement custom logic for robust validation.