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 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 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.
💰 Note you can now support this project via GitHub sponsors or PayPal.
✨ 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
asfloat
to save space in the serialization (32 bit va. 64 bit). #1719 #2044
🐛 Bug Fixes
- The functions to parse binary formats (
from_bson
,from_cbor
,from_msgpack
, andfrom_ubjson
) now properly respect theallow_exceptions=false
parameter. #1715 #2140 - The
contains
function for JSON Pointers now returnsfalse
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 theadd
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 withjson::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
⚡ 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 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
🔨 Further Changes
- Added links to GitHub sponsors and listed named sponsors.
- Documented the integration of the library via CMake FetchContent #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 package manager. #2004
- Added Build2 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 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
to indicate deprecated functions to have supporting compilers report which function to use instead.
🔥 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
are deprecated. Please use the member functionitems()
instead. - Functions
friend std::istream& operator<<(basic_json&, std::istream&)
andfriend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please usefriend std::istream& operator>>(std::istream&, basic_json&)
andfriend operator<<(std::ostream&, const basic_json&)
instead.
All deprecations are annotated with HEDLEY_DEPRECATED_FOR
to report which function to use instead.