fix: make the JSONCPP_USE_SECURE_MEMORY build compile and pass (#1709) Building with JSONCPP_USE_SECURE_MEMORY=1 fails in three separate ways, each hidden behind the previous one. No CI job builds this configuration, which is why they have accumulated. 1. allocator.h calls RtlSecureZeroMemory on the _WIN32 branch without including <windows.h>, so MSVC fails with error C3861. Removing that branch lets the portable volatile std::fill_n path handle Windows. The same fill was zeroing n bytes rather than n * sizeof(T), so for any T wider than a char, most of the allocation was never wiped. 2. jsontestrunner declares a std::string where the surrounding code uses Json::String. The two are the same type only in default builds, so the test runner does not compile under secure memory. 3. CZString's move-assignment released a key with releasePrefixedStringValue, but CZString keys come from duplicateStringValue and carry no length prefix. The destructor already uses the matching releaseStringValue. Under the default allocator this mismatch is survivable; under SecureAllocator the suite segfaults. Verified on MSVC 19.44, x64, C++17. Before: error C3861. With only the first two fixed: builds, then jsoncpp_test SEGFAULT. With all three: secure build compiles and 3/3 ctest suites pass. The default build is unaffected and also 3/3. Fixes #1399 Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.
JsonCpp is a C++ library that allows manipulating JSON values, including serialization and deserialization to and from strings. It can also preserve existing comment in deserialization/serialization steps, making it a convenient format to store user input files.
JsonCpp is a mature project in maintenance mode. Our priority is providing a stable, reliable JSON library for the long tail of C++ development.
JsonCpp remains a primary choice for developers who require comment preservation and support for legacy toolchains where modern C++ standards are unavailable. The library is intended to be a reliable dependency that does not require frequent updates or major migration efforts.
1.y.z (master): Actively maintained. Requires C++11.
0.y.z: Legacy support for pre-C++11 compilers. Maintenance is limited to critical security fixes.
00.11.z: Discontinued.
Major versions maintain binary compatibility. Critical security fixes are accepted for both the master and 0.y.z branches.
[!NOTE] Package manager ports (vcpkg, Conan, etc.) are community-maintained. Please report outdated versions or missing generators to their respective repositories.
meson wrap install jsoncpp
For projects requiring a single-header approach, JsonCpp provides a script to generate an amalgamated source and header file.
You can generate the amalgamated files by running the following Python script from the top-level directory:
python3 amalgamate.py
This will generate a dist directory containing jsoncpp.cpp, json/json.h, and json/json-forwards.h. You can then drop these files directly into your project's source tree and compile jsoncpp.cpp alongside your other source files.
Documentation is generated via Doxygen. Additional information is available on the Project Wiki.
JsonCpp is licensed under the MIT license, or public domain where recognized. See LICENSE for details.