JsonCpp Documentation

repository·master·Indexed 27 days ago

https://github.com/open-source-parsers/jsoncpp

A 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.

Tokens
549
Snippets
3
Records
6
Agent score
44%

What's inside JsonCpp

  1. Overview of JsonCpp

    master
    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.
  2. Use Amalgamated source for single-header integration

    master

    If 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 dist directory containing jsoncpp.cpp, json/json.h, and json/json-forwards.h. You can then include these files directly in your project and compile jsoncpp.cpp with your source code.

    python3 amalgamate.py
  3. Select the correct JsonCpp version for your compiler

    master

    JsonCpp 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.
  4. Detect ABI incompatibilities using `-Wabi-tag`

    master
    Some ABI incompatibilities do not change symbol names (for example, a class containing a std::string member). To detect these potential issues, you can use the -Wabi-tag compiler option. This enables warnings for new types and functions annotated with the abi_tag attribute that may cause incompatibilities.
  5. Resolve linker errors related to `std::__cxx11` or `[abi:cxx11]`

    master

    If you encounter linker errors involving undefined references to symbols in the std::__cxx11 namespace or the [abi:cxx11] tag, it typically means you are linking object files compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. 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