Skip to content

JSON for Modern C++ version 3.12.0

Latest
Compare
Choose a tag to compare
@nlohmann nlohmann released this 11 Apr 08:43
· 5 commits to develop since this release
55f9368

Release date: 2025-04-11
SHA-256: aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63 (json.hpp), b8cb0ef2dd7f57f18933997c9934bb1fa962594f701cd5a8d3c2c80541559372 (include.zip), 42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa (json.tar.xz)

Summary

This release fixes some bugs found in the 3.11.3 release and adds some new features.

All changes are backward-compatible.

💰 Note you can support this project via GitHub sponsors or PayPal.

Key updates and enhancements

  • Diagnostic byte positions: A new macro, JSON_DIAGNOSTIC_POSITIONS, introduces member functions to query the byte positions of values in the input they were parsed from. When enabled, this information is also included in exceptions to help pinpoint errors. #4517 #4455 #4570 #4569 #4572 #4571 #4579 #4585 #4561
  • Enhanced conversion macros: The conversion macros for arbitrary types now include several upgrades:
  • Support for std::optional: The library now supports conversions from/to std::optional types when compiled with C++17. #1749 #4036
  • Flexible string compatibility: Functions patch, diff, and flatten now work with arbitrary string types. #4536 #4134 #4613 #4019
  • Binary format enhancements:
    • The BJData mapping now supports draft 3, including optimized binary array types. #4513 #4588
    • The BSON mapping has added support for unsigned 64-bit integers. #4590 #4535 #3894
    • The get_number function used in the binary format implementations has been optimized to read multiple bytes at once. #4391
  • Multidimensional array conversion: Multidimensional C-style arrays can now be directly converted to JSON. #4262 #4248
  • Filesystem paths in UTF-8: The conversions from/to std::filesystem::path are now encoded to UTF-8 strings by default on all operating systems. #4271 #4631
  • CMake 4.0 support. By adjusting the CMake minimal version to 3.5, CMake 4.0 can be used without warning or error. #4709

Changes and fixes

Warnings

The quality assurance page gives an overview of the warning flags used during the tests.

Compiler warnings

  • Suppress weak-vtables warning for exceptions. #4500 #4087
  • Add 40+ GCC warning flags for GCC 14.2.0. #4524
  • Fix ignored attribute warning during build. #4670
  • Add explanation for suppressed CodeQL issues. #4362 #4361
  • Move compiler flags to separate CMake files (GCC, Clang). #4560

Clang-Tidy

  • Suppress warnings modernize-use-std-numbers,
    readability-redundant-member-init, and bugprone-unused-local-non-trivial-variable. #4276
  • Suppress warnings modernize-type-traits and modernize-avoid-c-arrays in NLOHMANN_JSON_SERIALIZE_ENUM. #4497 #3924
  • Suppress warning boost-use-ranges as we do not want to rely on Boost. #4489
  • Suppress warning modernize-use-designated-initializers as designated initializers are a C++20 feature. #4489
  • Suppress warning modernize-use-ranges as ranges are a C++20 feature. #4489
  • Suppress warning clang-analyzer-webkit.NoUncountedMemberChecker as we are using pointers internally. #4701
  • Fix warning modernize-use-integer-sign-comparison . #4558

Build

CMake

  • Adjust CMake minimal version to 3.5. #4709
  • Allow overriding the CMake target name via variable NLOHMANN_JSON_TARGET_NAME. #4483
  • Add CPack support. #4459
  • Adjust CMake to generate a pkg-config file that follows the pkg-config conventions. #4456

Package Managers

  • Remove alwayslink=True Bazel flag. #4396
  • Improve Bazel support by switching to Bzlmod. #4584
  • Add VisionOS support to Swift Package Manager Package.swift definition file. #4611
  • Remove wsjcpp package manager support. #4623

CI

Tests

  • Add test for libstdc++. #4495
  • Skip enum tests when JSON_DisableEnumSerialization=ON. #4504 #4384
  • Add a build step to build the documentation. #4549
  • Fix the coverage job. #4595
  • Add comment on reproducible builds. #4494 #4496

Infrastructure

  • Remove unsupported macos-11 image; the following Xcode versions are no longer tested in the CI: '11.7', '12.4', '12.5.1', '13.0'. #4489
  • Add macos-13 image to test Xcode versions '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2'. #4489
  • Add macos-14 image to test Xcode versions '15.3', '15.4'. #4489
  • Add macos-15 image to test Xcode versions '16.0', '16.1'. #4489
  • Test GCC versions '4.8', '4.9', '5', '6' on json-ci image as these versions are no longer work on the respective gcc images (checkout fails). #4489
  • Add tests for GCC versions '13', '14'. #4489
  • Add tests for Clang versions '16', '17', '18', '19'. #4489
  • Update README with a table of compilers/OS used in the CI. #4489
  • Apply security best practices by StepSecurity. #4539 #4546 #4058 #4547 #4550 #4551
  • Use Dependabot to automatically update GitHub actions and Python tools used in the CI. #4489 #4541 #4540 #4543 #4544 #4545 #4542 #4548 #4557 #4567 #4600 #4601 #4602 #4603 #4604 #4615 #4614 #4616 #4617 #4620 #4624 #4625 #4634 #4635 #4646 #4648 #4652 #4659 #4661 #4664 #4665 #4668 #4672 #4680 #4683 #4688 #4689 #4695 #4697 #4698 #4700 #4707 #4711 #4715 #4716 #4718 #4719 #4726
  • Use ubuntu-latest image to run Valgrind. #4575
  • Use Clang image to run iwyu. #4574
  • Adjust permissions in workflows. #4553
  • Use Python to install cppcheck. #4553
  • Move requirements.txt files for cppcheck, cpplint, and reuse to central location. #4553
  • Adjust cppcheck call. #4553
  • Add code exclusions to source files. #4553
  • Migrate stalebot to GitHub action. #4560
  • Remove deprecated .lgtm.yml file. #4560
  • Add CI steps for C++26. #4560
  • Add Xcode 16.2 (macOS) and Clang 3.4 (Ubuntu) action. #4560
  • Simplify Ubuntu workflow to use ubuntu-latest more often and reduce dependencies to more exotic containers. #4560
  • Add DCO requirement: all commits since January 17, 2025, need to be signed off. #4560
  • Remove .pre-commit-config.yml file. #4560
  • Pull update for tests/thirdparty/imapdl/filterbr.py. #4560
  • Make gdb-pretty-printer work with older Python versions. #4691 #4693
  • Update the REUSE integration. #4521

Indentation and amalgamation

  • Adjust and modernize flags for Artistic Style. #4277 #4275 #4573
  • Fix deprecation warning in amalgamation CI check. #4227

Documentation

The documentation website contains all project documentation.

Fixed documentation

Added documentation

Improved documentation

Package Manager documentation

Documentation implementation

  • Replace PlantUML by Mermaid. #4026
  • Serve assets (fonts, CSS) locally. #4560
  • Update Python requirements. #4516