Skip to content

JSON for Modern C++ version 3.1.0

Compare
Choose a tag to compare
@nlohmann nlohmann released this 01 Feb 23:08
· 2194 commits to develop since this release
97309f0

Release date: 2018-02-01
SHA-256: d40f614d10a6e4e4e80dca9463da905285f20e93116c36d97d4dc1aa63d10ba4 (json.hpp), 2b7234fca394d1e27b7e017117ed80b7518fafbb4f4c13a7c069624f6f924673 (include.zip)

Summary

This release adds support for the UBJSON format and JSON Merge Patch. It also contains some minor changes and bug fixes. All changes are backward-compatible.

✨ New features

  • The library now supports UBJSON (Universal Binary JSON Specification) as binary format to read and write JSON values space-efficiently. See the documentation overview for a comparison of the different formats CBOR, MessagePack, and UBJSON.
  • JSON Merge Patch (RFC 7386) offers an intuitive means to describe patches between JSON values (#876, #877). See the documentation of merge_patch for more information.

⚡ Improvements

  • The library now uses the Grisu2 algorithm for printing floating-point numbers (based on the reference implementation by Florian Loitsch) which produces a short representation which is guaranteed to round-trip (#360, #935, #936).
  • The UTF-8 handling was further simplified by using the decoder of Björn Hoehrmann in more scenarios.

🚚 Reorganization

  • Though the library is released as a single header, its development got more and more complicated. With this release, the header is split into several files and the single-header file json.hpp can be generated from these development sources. In the repository, folder include contains the development sources and single_include contains the single json.hpp header (#700, #906, #907, #910, #911, #915, #920, #924, #925, #928, #944).
  • The split further allowed for a forward declaration header include/nlohmann/json_fwd.hpp to speed up compilation times (#314).

🔨 Further changes

  • Google Benchmark is now used for micro benchmarks (see benchmarks folder, #921).
  • The serialization (JSON and binary formats) now properly work with the libraries string template parameter, allowing for optimized string implementations to be used in constraint environments such as embedded software (#941, #950).
  • The exceptional behavior can now be overridden by defining macros JSON_THROW_USER, JSON_TRY_USER, and JSON_CATCH_USER, defining the behavior of throw, try and catch, respectively. This allows to switch off C++'s exception mechanism yet still execute user-defined code in case an error condition occurs (#938).
  • To facilitate the interplay with flex and Bison, the library does not use the variable name yytext any more as it could clash with macro definitions (#933).
  • The library now defines NLOHMANN_JSON_VERSION_MAJOR, NLOHMANN_JSON_VERSION_MINOR, and NLOHMANN_JSON_VERSION_PATCH to allow for conditional compilation based on the included library version (#943, #948).
  • A compilation error with ICC has been fixed (#947).
  • Typos and links in the documentation have been fixed (#900, #930).
  • A compiler error related to incomplete types has been fixed (#919).
  • The tests form the UTF-8 decoder stress test have been added to the test suite.

🔥 Deprecated functions

  • Function iterator_wrapper has been deprecated (#874). Since its introduction, the name was up for discussion, as it was too technical. We now introduced the member function items() with the same semantics. iterator_wrapper will be removed in the next major version (i.e., 4.0.0).

Furthermore, the following functions are deprecated since version 3.0.0 and will be removed in the next major version (i.e., 4.0.0):

Please use friend std::istream& operator>>(std::istream&, basic_json&) and friend operator<<(std::ostream&, const basic_json&) instead.