* Migrate ci_icpc/ci_test_compilers_gcc_old/ci_infer off custom json-ci image Replaces the last three consumers of ghcr.io/nlohmann/json-ci with official images: ci_icpc now uses Intel's own intel/oneapi-hpckit:2023.2.1-devel-ubuntu22.04 (the last release with classic icc/icpc before Intel dropped it in oneAPI 2024.0), ci_test_compilers_gcc_old installs old GCCs on official ubuntu:20.04 via the same PPA/archive setup the custom image used (working around actions/checkout's incompatibility with official gcc:4/5/6 images), and ci_infer runs directly on ubuntu-latest, fetching Facebook's official Infer release tarball inline instead of a maintained image. No job in ubuntu.yml references the custom image anymore. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Update quality-assurance compiler table for CI image migration Reflects the ci_icpc/ci_test_compilers_gcc_old container migration: the old-GCC jobs (4.8/4.9/5/6) now compile inside official ubuntu:20.04 rather than the custom Focal-based json-ci image (same OS, just now attributed to the official image), and ci_icpc now uses Intel's official intel/oneapi-hpckit:2023.2.1-devel-ubuntu22.04, bumping the reported ICC version from 2021.5.0 to 2021.10.0 and the OS from Ubuntu 20.04.3 to 22.04. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix CI failures from the json-ci image migration - ci_icpc: the official intel/oneapi-hpckit image has no CMake preinstalled (the custom image bundled one); add the missing lukka/get-cmake step. - ci_test_compilers_gcc_old: official ubuntu:20.04 has no build tool, so CMake's default Unix Makefiles generator failed with "CMAKE_MAKE_PROGRAM is not set"; install make alongside the PPA-provided g++. - ci_infer: Infer v1.1.0's bundled Clang frontend can't parse GCC 14's headers (ubuntu-latest's default toolchain), failing with parse errors in <bits/unicode.h>; bump to the latest release, v1.3.0, whose newer bundled frontend understands them (release asset also renamed upstream from infer-linux64-v1.1.0.tar.xz to infer-linux-x86_64-v1.3.0.tar.xz). Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix ci_test_compilers_gcc_old: g++-6 missing from xenial-only archives My inline PPA/archive replication only added the xenial main/universe suites, but g++-6 isn't available there ("has no installation candidate"). The original custom Dockerfile also pulled from bionic main/universe and xenial-updates main/universe; add those back to match. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix ci_test_compilers_gcc_old: install git for CMake's FetchContent tests Official ubuntu:20.04 ships no git at all (actions/checkout only succeeded via its API-download fallback). The cmake_fetch_content(2) tests invoke CMake's own ExternalProject_Add, which needs a real git binary and failed with "could not find git for clone of json-populate". Install git alongside the other build prerequisites. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix ci_icpc: drop redundant setvars.sh sourcing Unlike the old custom image, the official intel/oneapi-hpckit image already has the oneAPI environment (icc/icpc on PATH) baked in at the container level. Explicitly re-sourcing setvars.sh in the Build step failed with "setvars.sh has already been run. Skipping re-execution." (exit code 3, aborting the step under `sh -e`). Drop the now-unnecessary sourcing. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix ci_icpc: exclude classic ICC from the std::span regression test Bumping to Intel's official intel/oneapi-hpckit:2023.2.1 image (see previous commit) also bumped classic icc/icpc from 2021.5.0 to 2021.10.0. The newer version's __has_include(<span>) now returns true, but it still can't actually compile std::span/std::as_bytes usage: error: namespace "std" has no member "as_bytes" error: namespace "std" has no member "span" Exclude __ICC/__INTEL_COMPILER the same way _LIBCPP_VERSION is already excluded for issue #4490. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix amalgamation/style check: indent comment per astyle Verified with the pinned astyle 3.4.13 (make install_astyle) locally; no further diff. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix ci_icpc: skip UTF-8 u8-literal comparison test on classic ICC test-deserialization_cpp20 failed: ERROR: CHECK( j2["emoji"] == "😀" ) is NOT correct! check_utf8() only guards against MSVC's ANSI-codepage quirk (its docstring example), but classic ICC has an analogous problem: it doesn't encode a narrow string literal containing non-ASCII source characters as UTF-8, so comparing a decoded u8R"(...)" literal against a narrow literal with the same characters fails. Extend the existing guard. Verified with the pinned astyle 3.4.13; no diff. Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
16 KiB
Quality assurance
Ensuring quality is paramount for this project, particularly because numerous other projects depend on it. Each commit to the library undergoes rigorous checks against the following requirements, and any violations will result in a failed build.
C++ language compliance and compiler compatibility
!!! success "Requirement: Compiler support"
Any compiler with complete C++11 support can compile the library without warnings.
Note: C++20 modules support may hit compiler-specific issues not covered by the general compiler matrix below. See Modules for known issues and workarounds.
Note: Some modern features (like C++20 ranges or filesystem support) may be disabled on specific broken or incomplete toolchains even when standard feature-test macros indicate support. See JSON_HAS_RANGES and JSON_HAS_FILESYSTEM for details on known exclusions.
-
The library is compiled with 50+ different C++ compilers with different operating systems and platforms, including the oldest versions known to compile the library.
??? abstract "Compilers used in continuous integration"
| Compiler | Architecture | Operating System | CI | |----------------------------------------------|--------------|-----------------------------------|-----------| | AppleClang 15.0.0.15000040; Xcode 15.0.1 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | | AppleClang 15.0.0.15000100; Xcode 15.1 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | | AppleClang 15.0.0.15000100; Xcode 15.2 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | | AppleClang 15.0.0.15000309; Xcode 15.3 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | | AppleClang 15.0.0.15000309; Xcode 15.4 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | | AppleClang 16.0.0.16000026; Xcode 16 | arm64 | macOS 15.2 (Sequoia) | GitHub | | AppleClang 16.0.0.16000026; Xcode 16.1 | arm64 | macOS 15.2 (Sequoia) | GitHub | | AppleClang 16.0.0.16000026; Xcode 16.2 | arm64 | macOS 15.2 (Sequoia) | GitHub | | AppleClang 17.0.0.17000013; Xcode 16.3 | arm64 | macOS 15.5 (Sequoia) | GitHub | | AppleClang 17.0.0.17000013; Xcode 16.4 | arm64 | macOS 15.5 (Sequoia) | GitHub | | AppleClang 17.0.0.17000319; Xcode 26.0.1 | arm64 | macOS 15.5 (Sequoia) | GitHub | | Clang 3.4.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 3.5.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 3.6.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 3.7.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 3.8.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 3.9.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 4.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 5.0.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 6.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 7.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 8.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 9.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 10.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 11.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 11.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 12.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 12.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 13.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 13.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 14.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 14.0.6 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 15.0.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 15.0.7 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 16.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 16.0.6 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 17.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 18.1.8 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 18.1.8 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 19.1.5 with MSVC-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 19.1.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 19.1.7 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 20.1.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | Clang 20.1.8 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | Clang 21.1.8 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | CUDA 11.8.0 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub | | CUDA 12.1.1 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub | | CUDA 12.6.3 (nvcc) | x86_64 | Ubuntu 22.04 LTS | GitHub | | Emscripten 4.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 4.8.5 | x86_64 | Ubuntu 20.04 LTS | GitHub | | GNU 4.9.3 | x86_64 | Ubuntu 20.04 LTS | GitHub | | GNU 5.5.0 | x86_64 | Ubuntu 20.04 LTS | GitHub | | GNU 6.4.0 | x86_64 | Ubuntu 20.04 LTS | GitHub | | GNU 7.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 8.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 9.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 9.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 9.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 10.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 11.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 11.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 12.2.0 (MinGW-W64 i686-ucrt-posix-dwarf) | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | GNU 12.2.0 (MinGW-W64 x86_64-ucrt-posix-seh) | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | GNU 12.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 13.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 14.2.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 15.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 16.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | | GNU 16.1.0 | arm64 | Linux 6.1.100 | Cirrus CI | | icpc (ICC) 2021.10.0 20230609 | x86_64 | Ubuntu 22.04 LTS | GitHub | | icpx (Intel oneAPI DPC++/C++) 2025.3.2 | x86_64 | Ubuntu 24.04 LTS | GitHub | | nvc++ (NVIDIA HPC SDK) 25.5-0 | x86_64 | Ubuntu 22.04 LTS | GitHub | | MSVC 19.0.24241.7 | x86 | Windows 8.1 | AppVeyor | | MSVC 19.16.27035.0 | x86 | Windows-10 (Build 14393) | AppVeyor | | MSVC 19.29.30157.0 | x86 | Windows-10 (Build 17763) | AppVeyor | | MSVC 19.44.35207.0 | arm64 | Windows 11 (Build 26200) | GitHub | | MSVC 19.44.35214.0 | x86 | Windows Server 2022 (Build 20348) | GitHub | | MSVC 19.44.35214.0 | x86_64 | Windows Server 2022 (Build 20348) | GitHub | | MSVC 19.51.36231.0 | x86 | Windows Server 2025 (Build 26100) | GitHub | | MSVC 19.51.36231.0 | x86_64 | Windows Server 2025 (Build 26100) | GitHub | -
The library is compiled with all C++ language revisions (C++11, C++14, C++17, C++20, C++23, and C++26) to detect and fix language deprecations early.
-
The library is checked for compiler warnings:
-
On Clang,
-Weverythingis used with 8 exceptions.??? abstract "Clang warnings"
```cmake --8<-- "../../../cmake/clang_flags.cmake" ``` -
On GCC, 300+ warnings are enabled with 8 exceptions.
??? abstract "GCC warnings"
```cmake --8<-- "../../../cmake/gcc_flags.cmake" ```
-
C++ standard library compliance
!!! success "Requirement: No prerequisites"
The library has no prerequisites other than the Standard Template Library (STL).
- The library is compiled and tested with both libc++ and libstdc++ to detect subtle differences or incompatibilities.
- The code checked with Include What You Use (IWYU) that all required standard headers are included.
- On Windows, the library is compiled with
<Windows.h>being included to detect and avoid common bugs. - The library is compiled with exceptions disabled to support alternative means of error handling.
Stable public API
!!! success "Requirement: Stable public API"
Any change to the library does not break the public API.
- All public API functions are tested with a variety of arguments.
- The library is compiled and tested with different template arguments for number, string, array, and object types.
- Unit tests cover all lines of the code base.
- Every exception of the library is thrown in the test suite, and the error messages and exception ids are checked.
!!! success "Requirement: Complete documentation"
The public API is extensively documented.
- Every public API function has a dedicated page in the API reference documentation with a self-contained code example.
- All examples in the documentation are tested, and changes in their output are treated as an error.
Robust input processing
!!! success "Requirement: Standards compliance"
The library is compliant to JSON as defined in [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259).
- The lexer is tested with all valid Unicode code points and all prefixes of all invalid Unicode code points.
- The parser is tested against extensive correctness suites for JSON compliance.
- In addition, the library is continuously fuzz-tested at OSS-Fuzz where the library is checked against billions of inputs.
Static analysis
!!! success "Requirement: State-of-the-art code analysis"
The code is checked with state-of-the-art static code analysis tools.
-
The code is checked with the latest Clang-Tidy.
??? abstract "Clang-Tidy configuration (.clang-tidy)"
```ini --8<-- "../../../.clang-tidy" ``` -
The code is checked with the latest Cppcheck with all warnings enabled.
-
The code is checked with the latest Clang Static Analyzer with 89 enabled rules.
-
The code is checked with Infer.
-
The code is checked with Codacy.
Dynamic analysis
!!! success "Requirement: Correctness"
The library is checked for memory correctness and absence of undefined behavior.
- The test suite is executed with enabled runtime assertions to check invariants and preconditions of functions to detect undefined behavior.
- The test suite is executed with Valgrind (Memcheck) to detect memory leaks.
- The test suite is executed with Sanitizers (address sanitizer, undefined behavior sanitizer, integer overflow detection, nullability violations).
Style check
!!! success "Requirement: Common code style"
A common code style is used throughout all code files of the library.
-
The code is formatted with Artistic Style (astyle) against a style configuration that is also enforced in the CI.
??? abstract "Astyle configuration (tools/astyle/.astylerc)"
```ini --8<-- "../../../tools/astyle/.astylerc" ``` -
The code style is checked with cpplint with 61 enabled rules.
Simple integration
!!! success "Requirement: Single header"
The library can be used by adding a single header to a C++ project.
- An amalgamation script is used to check if the source code is exposed as a self-contained single-header file.
- The test suite is checked against the amalgamated source file as well as the individual source file.
!!! success "Requirement: CMake as primary development tool"
All library functions are exposed and usable by CMake.
- All library options are exposed as CMake options and tested.
- The library is tested against relevant CMake versions:
- CMake 3.5 (the earliest supported)
- CMake 3.31.6 (the latest 3.x release)
- CMake 4.0.0 (a very recent release)