A single-header JSON parser for C and C++ that performs a single allocation for the entire DOM.
json.h is a single-header JSON parsing library for C and C++. It reads JSON strings and constructs a read-only Document Object Model (DOM) using only one memory allocation, making it fast and resource-efficient. It solves the need for a simple, dependency-free JSON parser in native applications.
C and C++ developers working on embedded systems, game engines, or performance-sensitive applications where a lightweight, no-dependency JSON parser is required.
Developers choose json.h for its minimal footprint, ease of integration (single header), and efficient single-allocation design. It offers extended JSON5 support without sacrificing simplicity or portability.
🗄️ single header json parser for C and C++
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Just #include "json.h" to use, eliminating complex build systems and dependencies, making integration trivial as highlighted in the README.
Parses JSON into one contiguous memory block, reducing fragmentation and improving performance, which is core to its design philosophy.
Through configurable flags like json_parse_flags_allow_json5, it supports JSON5 and simplified JSON features, offering flexibility for non-standard inputs.
Functions such as json_value_as_string and json_value_is_true simplify DOM traversal, making code more readable and less error-prone, as shown in examples.
The parsed JSON is immutable, so any modification requires extracting and cloning subtrees with json_extract_value, which can be inefficient and cumbersome.
Users must explicitly free the single allocation with free(), risking memory leaks if not handled properly, especially in error-prone or complex code paths.
Error handling is minimal by default; enabling detailed location information with json_parse_flags_allow_location_information increases memory usage and requires casting to specialized structs.