JsonCpp Documentation
repository·master·Indexed 27 days ago
https://github.com/open-source-parsers/jsoncppA mature C++ library for JSON serialization and deserialization that supports preserving comments within JSON files. The library provides versions for C++11 or newer (1.y.z) and legacy support for pre-C++11 compilers (0.y.z). It supports integration via the Meson build system or through amalgamated source files generated via a Python script.
What's inside JsonCpp
- JsonCpp is a C++ library for manipulating JSON values. It supports serialization and deserialization to and from strings. A key feature is its ability to preserve existing comments during deserialization and serialization, making it suitable for storing user configuration files.
Use Amalgamated source for single-header integration
masterIf you prefer a single-header/single-source approach instead of managing multiple files, you can use the provided Python script to generate an amalgamated version of the library. This generates a
distdirectory containingjsoncpp.cpp,json/json.h, andjson/json-forwards.h. You can then include these files directly in your project and compilejsoncpp.cppwith your source code.python3 amalgamate.pyIntegrate JsonCpp using Meson
masterYou can add JsonCpp to your project using the Meson build system by installing the wrap file.
meson wrap install jsoncppSelect the correct JsonCpp version for your compiler
masterJsonCpp provides different branches based on your C++ standard requirements:
1.y.z(master): The actively maintained version. Requires C++11 or newer.0.y.z: Legacy support for pre-C++11 compilers. Maintenance is limited to critical security fixes.
Detect ABI incompatibilities using `-Wabi-tag`
masterSome ABI incompatibilities do not change symbol names (for example, a class containing astd::stringmember). To detect these potential issues, you can use the-Wabi-tagcompiler option. This enables warnings for new types and functions annotated with theabi_tagattribute that may cause incompatibilities.Resolve linker errors related to `std::__cxx11` or `[abi:cxx11]`
masterIf you encounter linker errors involving undefined references to symbols in the
std::__cxx11namespace or the[abi:cxx11]tag, it typically means you are linking object files compiled with different values for the_GLIBCXX_USE_CXX11_ABImacro. This often occurs when linking against a third-party library compiled with an older version of GCC.If the third-party library cannot be rebuilt with the new ABI, you must recompile your own code using the old ABI by setting
-D_GLIBCXX_USE_CXX11_ABI=0.g++ stringWrite.cpp -ljsoncpp -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -o stringWrite