Release date: 2020-06-14
SHA-256: be7bbfbc7c62c35aa6f27dfbdd950384f247dd9f2281b5930bdaa3a6ab95eef7 (json.hpp), 8590fbcc2346a3eefc341935765dd57598022ada1081b425678f0da9a939a3c0 (include.zip)
Summary
It has been six months since the last release, and a lot of minor changes and bug fixes have accumulated. Nonetheless, JSON for Modern C++ 3.8.0 is a feature release.
- With **binary values** we greatly extend the support for binary formats such as CBOR, BSON, or MessagePack. By adding a new value type to the JSON class, binary values can be read and written, and even shared between different formats. See [the documentation](https://github.com/nlohmann/json#binary-formats-bson-cbor-messagepack-and-ubjson) for examples.
- Furthermore, we overworked the **input adapters**; that is, the way input is read by the parsers. Now any container is supported via the `LegacyInputIterator` concept. See [the documentation](https://github.com/nlohmann/json#custom-data-source) for examples. At the same time, we could improve the performance by 3-10%.
All changes are backward-compatible. See below the complete list of changes.
:moneybag: Note you can now **support this project** via [GitHub sponsors](https://github.com/sponsors/nlohmann) or [PayPal](http://paypal.me/nlohmann).
:sparkles: New Features
- The library now supports binary values for CBOR (byte arrays), BSON, and MessagePack (bin, ext, fixext). The values are parsed into a byte vector for further processing. 483 757 1129 1509 1662 1668 2064 2069 2071 2082 2099
- The input adapters have been generalized to read from any container including user-defined containers via `LegacyInputIterator`. The encoding of the input is implicitly derived from the size of the value type: UTF-8 (1 byte), UTF-16 (2 bytes), and UTF-32 (4 bytes) are supported. 1813 2145 2174 2178
- CBOR now encodes floating-point numbers that can be represented by a `float` as `float` to save space in the serialization (32 bit va. 64 bit). 1719 2044
:bug: Bug Fixes
- The functions to parse binary formats (`from_bson`, `from_cbor`, `from_msgpack`, and `from_ubjson`) now properly respect the `allow_exceptions=false` parameter. 1715 2140
- The `contains` function for JSON Pointers now returns `false` in all cases a syntactically correct JSON Pointer refers to a non-existing value. Previously, an exception was raised if a JSON Pointer referred to an array, but did not consist of a number. 1942 1982 2019
- Fixed the JSON Pointer parser which accepted numbers with leading `+` as array index. 1990
- Fixed JSON Patch generation to properly use `/-` in the `add` operation for arrays. 1983 2054
- Fixed compilation errors using GCC 10. 1912 1920 2034
- Fixed compilation errors using MSVC 2019. 1695 1810 1958 2006 2008 2009
- Fixed a preprocessor check for some MSVC versions. 2112 2137
- Fixed possible memory leak in `push_back`. 1971 2025
- Removed broken overload of the `value()` function with `json::value_t type` parameter. 2086 2104
- Removed values from arrays in case they are discarded by a parser callback function. Such values remained in the array with type `discarded` before. 1972 2153
:zap: Improvements
- The input adapters are now used via templates rather than inheriting from an abstract base class. This brings a 3-10% speedup for all parsers. 1457 1950
- Test files are now downloaded from an [external repository](https://github.com/nlohmann/json_test_data) such that the code repository got much smaller and can be used as submodule more easily. #96 482 556 567 620 732 1066 1184 1185 1235 1497 1572 1790 2081
- Made CMake's version config file architecture-independent. 1697 1746
:hammer: Further Changes
- Added links to [GitHub sponsors](https://github.com/sponsors/nlohmann) and listed named sponsors.
- Documented the integration of the library via CMake [FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) #2073 2074
- Doozer CI was removed as it seems to exist no longer. 2080
- Added GitHub Actions workflows to build with Ubuntu, macOS, and Windows.
- Added GCC 10.1 to the continuous integration. 2136
- Fixed the Coveralls integration. 2100
- Fixed the error message for invalid surrogate pairs. 2076
- Fixed documentation. 1853 1857 1895 1903 1907 1915 1917 1918 1923 1956 1979 1980 2002 2060 2077 2142 2143 2152
- Added test cases for NaN value in CBOR. 2043
- Documented curious behavior when using the library with glibc. 1924 1933
- Fixed compiler warnings. 1939 1911 1967 1969 2049 2051 2053 2113 2116 2144 2177
- Updated Doctest to version 2.3.7. 2048 2050
- Updated Hedley to version 13.
- Removed `std::is_pod` usage as it is deprecated in C++20. 1913 2033 2109
- Added [wsjcpp](https://wsjcpp.org) package manager. #2004
- Added [Build2](https://build2.org/) package manager. #1909
- Fixed compiler warning in test case. 1871
- Updated copyright year. 2010
- Updated CMake tests. 1844
- Removed a duplicated test. 2158
- Removed outdated Travis macOS images for Xcode 8.3, Xcode 9.0, Xcode 9.1, and Xcode 9.2. Added Xcode 11.2 image.
- Added [FOSSA](https://app.fossa.com/projects/git%2Bgithub.com%2Fnlohmann%2Fjson?ref=badge_shield) analysis.
- Header `<ciso646>` is deprecated in C++17 and not included if library is compiled with C++17. 2089 .2115
- Updated the templates for bug fix reports, feature requests, and questions.
- Added fuzz tests for the all UBJSON modes. 2182
- Used [`HEDLEY_DEPRECATED_FOR`](https://nemequ.github.io/hedley/api-reference.html#HEDLEY_DEPRECATED_FOR) to indicate deprecated functions to have supporting compilers report which function to use instead.
:fire: Deprecated functions
This release deprecates 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. 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.