github nlohmann/json v3.8.0
JSON for Modern C++ version 3.8.0

latest releases: v3.11.3, v3.11.2, v3.11.1...
4 years ago

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 as float 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, 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

⚡ Improvements

🔨 Further Changes

🔥 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):

All deprecations are annotated with HEDLEY_DEPRECATED_FOR to report which function to use instead.

Don't miss a new json release

NewReleases is sending notifications on new releases.