Nlohmann-json

Latest version: v3.11.3

Safety actively analyzes 688705 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 8

3.10.3

Release date: 2021-10-08
SHA-256: bac28658a4c9410faa55960a70c1ac541e8a51bbaae57dc395e23ca5abd3159a (json.hpp), 4ae5744bc1edd216c79f619fd49915c0e490e41b05434c2d2b89e078299f04ed (include.zip)

Summary

This release fixes two more bug introduced in release 3.10.0: the **extended diagnostics triggered assertions** when used with `update()` or when inserting elements into arrays. All changes are backward-compatible.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:bug: Bug Fixes

- Fix bug in the [`update()`](https://json.nlohmann.me/api/basic_json/update/) function when used with extended diagnostics. #3007 3008
- Fix bug when inserting into arrays when using extended diagnostics. 2926 3032 3037

:zap: Improvements

Binary formats

- Custom allocators are now supported when writing binary formats (e.g., CBOR, MessagePack) into a `std::vector`. 2982 2989

User-defined type support

- Allow conversion from types that do not define an explicit iterator type, but have a `begin()` and `end()` function. 3020

Tests and CI

- Updated the [Docker image](https://github.com/nlohmann/json-ci) used in the CI. #2981 2986
- Corrected the compiler version mentioned in the README file. 3040

Documentation

- Add script to generate docset for Dash, Velocity, and Zeal. 2967

:fire: Deprecated functions

Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

3.10.2

Release date: 2021-08-26
SHA-256: 059743e48b37e41579ee3a92e82e984bfa0d2a9a2b20b175d04db8089f46f047 (json.hpp), 61e605be15e88deeac4582aaf01c09d616f8302edde7adcaba9261ddc3b4ceca (include.zip)

Summary

This release is made days after the 3.10.1 release due to a bug in the release script: The [3.10.1 release](https://github.com/nlohmann/json/releases/tag/v3.10.1) at GitHub contained the correct files, but the associated tag [v3.10.1](https://github.com/nlohmann/json/tree/v3.10.1) points to the wrong commit. This release is made with a fixed build script. All changes are backward-compatible.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:zap: Improvements

- Fix the release scripts to correctly tag releases. 2973
- Fix some `-Wunused` warnings on `JSON_DIAGNOSTICS` when the library is built without CMake. 2975 2976

:fire: Deprecated functions

Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

3.10.1

Release date: 2021-08-24
SHA-256: 0b628af78a2f0f3e2ff41d8dfa18314dd53831ffc2720c2944192d9f53727f4d (json.hpp), 144268f7f85afb0f0fbea7c796723c849724c975f9108ffdadde9ecedaa5f0b1 (include.zip)

Summary

This release fixes a bug introduced in release 3.10.0: the **extended diagnostics triggered an assertion** when used with `ordered_json`. All changes are backward-compatible.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:bug: Bug Fixes

- Fix an assertion triggered in the extended diagnostics using `ordered_json`. 2962 2963
- Make GDB pretty-printer robust against unset variable names. 2950

:zap: Improvements

Warnings

- Add a missing header to `hash.hpp`. 2948
- Fix some `-Wextra-semi-stmt` warnings. 2957

Tests and CI

- Avoid duplicate builds in AppVeyor. 2952
- Remove an outdated test binary that is not supported any longer. 2941 2945
- Skip tests that would fail if CMake option `JSON_Install` is set to `OFF`. 2946 2947
- Move Travis jobs to travis-ci.com. 2938 2959
- Set stack size for some unit tests when building with MSVC. 2955 2961
- Add a regression test. 2960

Documentation

- Update the Homebrew command as [nlohmann-json](https://formulae.brew.sh/formula/nlohmann-json) is now in homebrew-core. #2943 2966
- Add example for integration via vcpkg. 2944 2954
- Fix a typo in the documentation. 2968

:fire: Deprecated functions

Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

3.10.0

Release date: 2021-08-17
SHA-256: 230f3a03cefd586661ebab577a347c973d97a770afb89e22c52abc3c2a19d0a7 (json.hpp), b5e3bfad07feba218a26a4f809fbb0d1e33450524bf5d7244cabc92cf8178c69 (include.zip)

Summary

JSON for Modern C++ 3.10.0 is the first release for over a year. It contains some new features and a lot of minor changes and bug fixes.

Most notably, it introduces [**extended diagnostics.**](https://json.nlohmann.me/home/exceptions/#extended-diagnostic-messages) By defining [`JSON_DIAGNOSTICS`](https://json.nlohmann.me/features/macros/#json_diagnostics) before including the `json.hpp`, a [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) is added to [exceptions](https://json.nlohmann.me/home/exceptions/) which helps to debug issues with object access, array indices, or mismatching types.

Another important change behind the curtains is a **fully overworked CI** which performs a lot of checks for every commit which should allow more frequent releases in the future.

All changes are backward-compatible.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:sparkles: New Features

- Add **extended diagnostics information** by adding a [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) to the [exception](https://json.nlohmann.me/home/exceptions/) messages indicating the exact location of a invalid type errors or out-of-bound errors.


[json.exception.type_error.302] (/address/housenumber) type must be number, but is string


Exceptions in the library are thrown in the local context of the JSON value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult. To create better diagnostics messages, each JSON value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is then provided as a JSON Pointer.

As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol [`JSON_DIAGNOSTICS`](https://json.nlohmann.me/features/macros/#json_diagnostics) to 1 before including `json.hpp`. See the [`documentation`](https://json.nlohmann.me/home/exceptions/#extended-diagnostic-messages) for more information. 932 1508 2562 2838 2866
- Add a [**GDB pretty printer**](https://github.com/nlohmann/json/tree/develop/third_party/gdb_pretty_printer) to facilitate reading `basic_json` values in GDB. #1952 2607
- Add a new value `store` to the [cbor_tag_handler_t](https://json.nlohmann.me/api/basic_json/cbor_tag_handler_t/) which allows to store the tags of CBOR values as binary subtypes. #2863 2908
- Add support for containers with non-default-constructible types. 2574 2576

:bug: Bug Fixes

- Fix a regression bug that failed `ordered_json` to be used when exceptions were switched off. 2347 2725 2934
- Added iterator range insertion for `ordered_json`. 2490 2512
- Change the type of binary subtypes to `std::uint64_t` to support subtypes >255. Furthermore, the return value of the `subtype()` function has been fixed to the documented value `-1` in case no subtype is given. 2863 2908
- Fix move constructor of internal `json_ref` type which created `null` values when compiled with `-fno-elide-constructors`. 2387 2405
- Fix the compilation of `input_adapter` for containers in edge cases. 2553
- Allow parsing from `std::byte` containers. 2413 2546 2550 2602 2869
- Fix memory leak in `to_json` in case a JSON value is reused. 2865 2872
- Fix compilation error in case symbol `EOF` was not found. 2755 2756
- Fix Compilation error when using `NLOHMANN_JSON_SERIALIZE_ENUM` with `ordered_json` on libc++. 2491 2825

Warnings

A lot of warnings have been fixed in this release. To make sure the library remains warning-free, the CI now breaks in case a warning is found in GCC (261 warning flags), Clang (flag `-Weverything` with 8 exceptions), or MSVC (flag `/W4`).

- Fix `-Wimplicit-fallthrough` warnings. 2348 2349
- Fix `-Wfloat-equal` warnings. 2909 2911
- Add assertions to suppress C28020 warnings. 2447
- Fix shadow warnings. 1759 2536 2444
- Fix compiler warnings in the test suite. 2537
- Fix issues found by Visual Studio Visual Assist 2615
- Fix unused parameter warning. 2646 2658 2668 2706 2707
- Remove HEDLEY annotation from `exception::what()` to fix C28204 warning. 2673 2680
- Suppress C4127 warning. 2592 2875
- Fix truncation warning. 2572 2874
- Fix useless cast warning. 1777 2114 2893 2902
- Fix unknown pragma warning. 2924 2925
- Fix `-Wswitch-enum` warnings. 2927
- Fix C4309 and C4100 warnings and treat all MSVC `/W4` warnings as error. 2930
- Suppress fewer warning flags. 2936

:zap: Improvements

Tests and CI

The CI chain has been completely overworked and now runs mostly on a dedicated [Docker Image](https://github.com/nlohmann/json-ci) that contains all relevant tools.

- Collected all CI calls in a [CMake file](https://github.com/nlohmann/json/blob/develop/cmake/ci.cmake) which can be enabled by setting `JSON_CI`.
- Linux now builds with Clang 3.5 to 12 and GCC 4.8 to 11 checking multiple C++ standards. 2540
- Windows builds with MSVC 2015 to 2019, MinGW (GCC 8), Clang 11 and 12, and Clang-CL 11 checking multiple C++ standards.
- Mac builds with Xcode 10.2.1 to Xcode 12.4 checking multiple C++ standards. 1798 2561 2737 2790 2817
- Use static analysis tools Clang-Tidy, Cppcheck, Valgrind, Google Sanitizers, Clang Static Analyzer, Cpplint, and Facebook Infer.
- Add internal checks for CMake flags, switched off exceptions, header amalgamation, self-contained headers, and exclusion of certain tests via CTest.
- Providers: Move most Travis/AppVeyor builds to GitHub Actions. Use [Drone CI](https://cloud.drone.io/nlohmann/json) for aarch64 build. Remove FOSSA. Properly select "Release" build for Travis CI builds. #2375 2689
- Remove `define private public` hack from test files. Instead, macro `JSON_PRIVATE_UNLESS_TESTED` is used in the source code which defaults to `private`, but can be set to `public` to test internals. 43 913 1985 2352

CMake

- Fixed issue in CMake file that overwrote `CMAKE_CXX_COMPILER` when the test suite was compiled. 2344 2384
- Only enable CMake options `JSON_BuildTests` and `JSON_Install` by default when the library is the main project. 2513 2514
- Add CTest label `not_reproducible` to skip non-reproducible tests. 2324 2560
- Formatted CMake files 2770
- Add a CMake option `JSON_SystemInclude` to use `SYSTEM` in `target_include_directories`. 2762
- Add CMake option `JSON_FastTests` (`OFF` by default) to which slow test suite.

Documentation

- Fixed typos in the documentation. 2354 2754
- Extended documentation for discarded values and `is_discarded()` function. 2360 2363
- Fix Markdown of README. 2582
- Fix example in README file. 2625 2659
- Fix example in parse exceptions documentation. 2679
- Overworked [documentation of number handling](https://json.nlohmann.me/features/types/number_handling/). #2747
- Add link to Conan Center package to README. 2771
- Added example for CPM.cmake. 2406
- Update README to use HTTPS everywhere. 2789
- Fixed consistency of `using` declarations in README. 2826
- Fix documentation of tests that required a Git checkout. 2845
- Fix code samples in GIF slideshow. 2457
- Update documentation to reference [RFC 8259](https://tools.ietf.org/html/rfc8259.html) as JSON standard.
- Add section on how to get support to README file.
- Replaced links to Doxygen documentation with new [API documentation](https://json.nlohmann.me/api/basic_json/).
- Documented the effect of a [bug](https://github.com/microsoft/STL/issues/2114) in Microsoft's STL that makes `what()` member function of exception objects unusable in case `_HAS_EXCEPTIONS=0` is set. #2824

Thirdparty

- Updated Hedley to version 15. 2367
- Updated Doctest to version 2.4.6. 2525 2538 2686 2687

:hammer: Further Changes

- Use C++14 constructs where available. 2533
- Fix `pkg-config.pc` generation. 2690
- Add possibility to set the C++ standard via macros `JSON_HAS_CPP_11`, `JSON_HAS_CPP_14`, `JSON_HAS_CPP_17`, and `JSON_HAS_CPP_20`. By defining any of these symbols, the internal check is overridden and the provided C++ version is unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be detected incorrectly. 2730 2731 2749
- Add preprocessor symbol `JSON_NO_IO`. When defined, headers `<cstdio>`, `<ios>`, `<iosfwd>`, `<istream>`, and `<ostream>` are not included and parse functions relying on these headers are excluded. This is relevant for environment where these I/O functions are disallowed for security reasons (e.g., Intel Software Guard Extensions (SGX)). 2728 2729 2842 2861
- Benchmarks are handled via `FetchContent` and require CMake version 3.11. Removed Google Benchmark copy. Fix default branch name for Google Benchmarks. 2795 2796
- Simplify object parser for CBOR. 2879 2598
- Cleaned up maintainer Makefiles

Licensing

- Clarified license of `is_complete_type` implementation. 2534
- License fix for `integer_sequence` and `index_sequence` implementation. 2683

:fire: Deprecated functions

Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

3.9.1

Release date: 2020-08-06
SHA-256: 7804b38146921d03374549c9e2a5e3acda097814c43caf2b96a0278e58df26e0 (json.hpp), 6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91 (include.zip)

Summary

This release fixes two bugs in the features introduced in release 3.9.0. The lexer did not accept **consecutive comments**, and **`ordered_json` lacked some functions** from `json`. All changes are backward-compatible.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:bug: Bug Fixes

- The lexer did not accept input with two or more consecutive comments (e.g. `/* one */ /* two */ []`). 2330 2332
- The newly introduced `ordered_json` container did not implement the complete interface of `basic_json` which broke existing code when `json` was replaced by `ordered_json`, in particular when trying to call `ordered_json::parse`. 2315 2319 2331

:hammer: Further Changes

- Install pkg-config file to `CMAKE_CURRENT_BINARY_DIR` instead of `CMAKE_BINARY_DIR` 2318
- Make installation directory of pkg-config file depend on `CMAKE_INSTALL_LIBDIR`. 2314
- Fix `-Wimplicit-fallthrough` warning. 2333
- Fix name of Homebrew formula in documentation. 2326 2327
- Fix typo in documentation. 2320

:fire: Deprecated functions

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.
- Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

3.9.0

Release date: 2020-07-27
SHA-256: d8089d52d285ef2c5368eb39ae665b39ea464206b1ca674a88a915c0245ff4f0 (json.hpp), 5b9b819aed31626aefe2eace23498cafafc1691890556cd36d2a8002f6905009 (include.zip)

JSON for Modern C++ 3.9.0 is a feature release that adds four long-awaited features, some requested five years ago.

- The parser functions have now an option to ignore `//` and `/* */` style **comments**. Though comments are not officially part of the JSON specification (see [here](https://github.com/nlohmann/json#comments-in-json) for a discussion), comment support was a frequently requested feature, and its implementation was much less effort than continuously explaining the lack of comment support.
- The second-most requested feature was a way to **preserve the insertion order of object keys**. Though this was possible via template specialization for a while, we now added a new type `nlohmann::ordered_json` as drop-in replacement for `nlohmann::json` for this.
- To circumvent unexpected behavior, **implicit conversions** can now be switched off with a CMake or preprocessor option.
- Last, but not least, a mapping between user-defined types and JSON can now be expressed using **convenience macros** by just listing the names of the member variables to read/write.

All changes are backward-compatible. See below the complete list of changes. See the [README](https://github.com/nlohmann/json/blob/develop/README.md) or the [documentation](https://nlohmann.github.io/json/) for more information.

:moneybag: Note you can **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).

:sparkles: New Features

- Add optional support for [**comments in JSON**](https://github.com/nlohmann/json#comments-in-json): passing parameter `ignore_comments` to the `parse` function will treat `//` and `/* */` comments like whitespace. 294 363 376 597 1513 2061 2212
- Add type `nlohmann::ordered_json` to [**preserve insertion order of object keys**](https://github.com/nlohmann/json#order-of-object-keys). `ordered_json` is a specialization of `basic_json` and can be used wherever `json` is used. 106 424 543 660 727 952 1106 1717 1817 2179 2206 2258
- Add CMake option `JSON_ImplicitConversions` and preprocessor symbol `JSON_USE_IMPLICIT_CONVERSIONS` to [**switch off implicit conversions**](https://github.com/nlohmann/json#implicit-conversions). Implicit conversions, though very practical, are also a source of subtle bugs or unexpected behavior and may be switched off by default in future versions. The new options allow to remove implicit conversions now. 958 1559
- Add [**convenience macros** `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` and `NLOHMANN_DEFINE_TYPE_INTRUSIVE`](https://github.com/nlohmann/json#simplify-your-life-with-macros) to simplify serialization/deserialization code for user-defined types. 2175 2225 2233 2267 2280 2287 2306 2313
- Add **high-precision number support for UBJSON**. Now, any JSON value can serialized to UBJSON, and exception `json.exception.out_of_range.407` will no longer occur for integers larger than 9223372036854775807 (`LLONG_MAX`). 2297 2286
- Write **binary subtype as CBOR tag**. 2244
- Add option to **ignore CBOR tags** as alternative to treat them as invalid input. 2308 2273 1968

:bug: Bug Fixes

- Fix bug in CBOR parser where `allow_exceptions` was not respected. 2299 2298
- Fix bug in CBOR parser where incomplete binary values or strings could crash the parser. 2293 2294

:zap: Improvements

- Make code compile with **Clang on Windows**. 2259 1119
- Use 32-bit float encoding in MessagePack wherever this is possible without loss of precision. 2201 2196
- Replace `std::hash<nlohmann::basic_json>` with a function that does not allocate memory. 2292 2285 2269

:hammer: Further Changes

- Use [GitLab Discussions](https://github.com/nlohmann/json/discussions) for support and feature requests. Removed and adjusted issue templates accordingly.
- Allow CMake 3.13+ to override options when using `FetchContent`. 2222
- Add support for [pkg-config](https://github.com/nlohmann/json#pkg-config). 2253
- Add CMake option `JSON_TestDataDirectory` to select directory of previously downloaded test data for situations where Internet access is forbidden during testing. 2189 2190
- Add [option to skip tests](https://github.com/nlohmann/json#execute-unit-tests) that assume the code is checked out via Git. 2189
- Add `JSON_ASSERT` macro to control behavior of assert calls. 2242
- Add CI step for [GitHub CodeQL analysis](https://github.com/nlohmann/json/actions?query=workflow%3A%22Code+scanning+-+action%22) (GitHub actions).
- Add CI step for Clang 9 and Clang 10 on Windows (GitHub actions). 2259
- Add CI step for Clang 10 CL with MSVC 2019 on Windows (GitHub actions). 2268
- Clean up GitHub actions CI. 2300
- Add CI step for Xcode 12 (Travis). 2262
- Add CI step for explicit conversions (Travis, AppVeyor).
- Remove `swap` specialization to support C++20. 2176
- Add missing check for `binary()` function in [SAX interface](https://github.com/nlohmann/json#sax-interface). 2282
- Add [test](https://github.com/nlohmann/json/tree/develop/test/cmake_target_include_directories/project) for CMake `target_include_directories`. #2279
- Add test to use library in multiple translation units. 2301
- Add more sections to new [project website](https://nlohmann.github.io/json/). #2312
- Fix warnings. 2304 2305 2303 2274 2224 2211 2203
- Cleanup maintainer Makefiles. 2264 2274
- Improve documentation. 2232
- Fix inconsistency in int-to-string function. 2193

:fire: Deprecated functions

Passing iterator pairs or pointer/length pairs to parsing functions (`basic_json::parse`, `basic_json::accept`, `basic_json::sax_parse`, `basic_json::from_cbor`, `basic_json::from_msgpack`, `basic_json::from_ubjson`, `basic_json::from_bson`) via initializer lists is deprecated. Instead, pass two iterators; for instance, call `basic_json::from_cbor(ptr, ptr+len)` instead of `basic_json::from_cbor({ptr, len})`.

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

- Function [`iterator_wrapper`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a0a8051760196ac813fd5eb3c8d5a2976.html#a0a8051760196ac813fd5eb3c8d5a2976) are deprecated. Please use the member function [`items()`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5961446010dfc494e0c247b4e9026977.html#a5961446010dfc494e0c247b4e9026977) instead.
- Functions [`friend std::istream& operator<<(basic_json&, std::istream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html#a60ca396028b8d9714c6e10efbf475af6) and [`friend std::ostream& operator>>(const basic_json&, std::ostream&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b) are deprecated. Please use [`friend std::istream& operator>>(std::istream&, basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8) and [`friend operator<<(std::ostream&, const basic_json&)`](https://nlohmann.github.io/json/doxygen/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html#a5e34c5435e557d0bf666bd7311211405) instead.

All deprecations are annotated with [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to report which function to use instead.

Page 2 of 8

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.