!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip) (274 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.3/json.hpp) (791 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.3/json.hpp.asc) (1 KB)
Release date: 2019-11-17 SHA-256: 3b5d2b8f8282b80557091514d8ab97e27f9574336c804ee666fda673a9b59926 (json.hpp), 87b5884741427220d3a33df1363ae0e8b898099fbc59f1c451113f6732891014 (include.zip)
This release fixes a bug introduced in release 3.7.2 which could yield quadratic complexity in destructor calls. All changes are backward-compatible.
reserve()
calls from the destructor which could lead to quadratic complexity. #1837 #1838This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.2/include.zip) (274 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.2/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.2/json.hpp) (791 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.2/json.hpp.asc) (1 KB)
Release date: 2019-11-10 SHA-256: 0a65fcbbe1b334d3f45c9498e5ee28c3f3b2428aea98557da4a3ff12f0f14ad6 (json.hpp), 67f69c9a93b7fa0612dc1b6273119d2c560317333581845f358aaa68bff8f087 (include.zip)
Project bad_json_parsers tested how JSON parser libraries react on deeply nested inputs. It turns out that this library segfaulted at a certain nesting depth. This bug was fixed with this release. Now the parsing is only bounded by the available memory. All changes are backward-compatible.
This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.1/include.zip) (273 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.1/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.1/json.hpp) (789 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.1/json.hpp.asc) (1 KB)
Release date: 2019-11-06 SHA-256: b5ba7228f3c22a882d379e93d08eab4349458ee16fbf45291347994eac7dc7ce (json.hpp), 77b9f54b34e7989e6f402afb516f7ff2830df551c3a36973085e2c7a6b1045fe (include.zip)
This release fixes several small bugs in the library. All changes are backward-compatible.
std::int64_t
minimum value. #1708 #1722contains()
function for JSON Pointers. #1727 #1741std::pair
and std::tuple
to json
. #1805 #1806 #1825 #1826iteration_proxy
. #1797json
to std::valarray
.items()
function can now be used with a custom string type. #1765json_pointer::back
const
. #1764 #1769ubuntu-latest
/GCC 7.4.0 as CI step.JSON_THROW_USER
, JSON_TRY_USER
, and JSON_CATCH_USER
macros to control user-defined exception handling.GLOB
from CMake files. #1779This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.7.0/include.zip) (143 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.7.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.7.0/json.hpp) (782 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.7.0/json.hpp.asc) (1 KB)
Release date: 2019-07-28 SHA-256: a503214947952b69f0062f572cb74c17582a495767446347ce2e452963fc2ca4 (json.hpp), 541c34438fd54182e9cdc68dd20c898d766713ad6d901fb2c6e28ff1f1e7c10d (include.zip)
This release introduces a few convenience functions and performs a lot of house keeping (bug fixes and small improvements). All changes are backward-compatible.
contains
function to check if a JSON pointer is valid without throwing exceptions, just like its counterpart for object keys. #1600to_string
to allow for generic conversion to strings. #916 #1585emplace_back
function, returning a reference to the added element just like C++17 is introducing this for std::vector
. #1609std::string_view
in the unit tests. #1634 #1639get_to
method to clear existing content before writing. #1511 #1555-Wc++17-extensions
warning. nodiscard
attributes are now only used with Clang when -std=c++17
is used. #1535 #1551GNUInstallDirs
to set library install directories. #1673json
type on the documentation start page. #1616value()
function with respect to type_error.302
exception. #1601JSON_BuildTests
, JSON_Install
, JSON_MultipleHeaders
, JSON_Sanitizer
, JSON_Valgrind
, JSON_NoExceptions
, JSON_Coverage
).JSON_DEPRECATED
, JSON_NODISCARD
, JSON_LIKELY
, JSON_UNLIKELY
, JSON_HAS_CPP_14
, or JSON_HAS_CPP_17
. Functions taking or returning pointers are annotated accordingly when a pointer will not be null.This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip) (136 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.6.1/json.hpp) (711 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.6.1/json.hpp.asc) (1 KB)
Release date: 2019-03-20 SHA-256: d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a (json.hpp), 69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf (include.zip)
This release fixes a regression and a bug introduced by the earlier 3.6.0 release. All changes are backward-compatible.
<Windows.h>
was included. #1531This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.6.0/include.zip) (136 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.6.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.6.0/json.hpp) (711 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.6.0/json.hpp.asc) (1 KB)
Release date: 2019-03-20 SHA-256: ce9839370f28094c71107c405affb3b08c4a098154988014cbb0800b1c44a831 (json.hpp), 237c5e66e7f8186a02804ce9dbd5f69ce89fe7424ef84adf6142e973bd9532f4 (include.zip)
ℹ️ This release introduced a regression. Please update to version 3.6.1!
This release adds some convenience functions for JSON Pointers, introduces a contains
function to check if a key is present in an object, and improves the performance of integer serialization. Furthermore, a lot of small bug fixes and improvements have been made. All changes are backward-compatible.
operator/
and operator/=
. JSON Pointers can be inspected with empty
, back
, and parent_pointer
, and manipulated with push_back
and pop_back
. #1434contains
to check whether an element exists in a JSON object with a given key. Returns false when called on non-object types. #1471 #1474JSON_Install
to control whether the library should be installed (default: on). #1330nodiscard
attribute to meta()
, array()
, object()
, from_cbor
, from_msgpack
, from_ubjson
, from_bson
, and parse
. #1433This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.5.0/include.zip) (133 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.5.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.5.0/json.hpp) (693 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.5.0/json.hpp.asc) (1 KB)
Release date: 2018-12-22 SHA-256: 8a6dbf3bf01156f438d0ca7e78c2971bca50eec4ca6f0cf59adf3464c43bb9d5 (json.hpp), 3564da9c5b0cf2e032f97c69baedf10ddbc98030c337d0327a215ea72259ea21 (include.zip)
This release introduces the support for structured bindings and reading from FILE*
. Besides, a few bugs have been fixed. All changes are backward-compatible.
Structured bindings are now supported for JSON objects and arrays via the items()
member function, so finally this code is possible:
for (auto& [key, val] : j.items()) { std::cout << key << ':' << val << '\n'; }
#1388 #1391
Added support for reading from FILE*
to support situations in which streams are nit available or would require too much RAM. #1370 #1392
eofbit
was not set for input streams when the end of a stream was reached while parsing. #1340 #1343-Wshadow
warning #1346std::snprintf
calls to avoid error in MSVC. #1337This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip) (132 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.4.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp) (689 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.4.0/json.hpp.asc) (1 KB)
Release date: 2018-10-30 SHA-256: 63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f (json.hpp), bfec46fc0cee01c509cf064d2254517e7fa80d1e7647fea37cf81d97c5682bdc (include.zip)
This release introduces three new features:
Furthermore, some effort has been invested in improving the parse error messages. Besides, a few bugs have been fixed. All changes are backward-compatible.
dump
function for examples. #1198 #1314NLOHMANN_JSON_SERIALIZE_ENUM
has been introduced. See the README section for more information. #1208 #1323parse error at 2: syntax error - invalid string: control character must be escaped; last read: '<U+0009>'
is now reported as parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0009 (HT) must be escaped to \u0009 or \t; last read: '<U+0009>'
. #1280 #1288 #1303This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.3.0/include.zip) (123 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.3.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.3.0/json.hpp) (635 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.3.0/json.hpp.asc) (1 KB)
Release date: 2018-10-05 SHA-256: f1327bb60c58757a3dd2b0c9c45d49503d571337681d950ec621f8374bcc14d4 (json.hpp), 9588d63557333aaa485e92221ec38014a85a6134e7486fe3441e0541a5a89576 (include.zip)
This release adds support for GCC 4.8. Furthermore, it adds a function get_to
to write a JSON value to a passed reference. Another topic of this release was the CMake support which has been overworked and documented.
Besides, a lot of bugs have been fixed and slight improvements have been made. All changes are backward-compatible.
get_to
to write a JSON value to a passed reference. The destination type is automatically derived which allows more succinct code compared to the get
function. #1227 #1231target_link_libraries
to not properly include nlohmann_json
. #1243 #1245 #1260-Wctor-dtor-privacy
warning. #1224JSON_CATCH_USER
led to duplicate macro definition of JSON_INTERNAL_CATCH
. #1213 #1214find_package(nlohmann_json)
without installing the library. #1202operator[]
is used with the wrong combination (json.exception.type_error.305) of JSON container type and argument type. Example: “cannot use operator[] with a string argument”. #1220 #1221to_json
or from_json
functions as such assertions do not play well with SFINAE. These assertions also led to problems with GMock. #960 #1212 #1228This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.2.0/include.zip) (124 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.2.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp) (636 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.2.0/json.hpp.asc) (1 KB)
Release date: 2018-08-20 SHA-256: ce6b5610a051ec6795fa11c33854abebb086f0fd67c311f5921c3c07f9531b44 (json.hpp), 35ee642558b90e2f9bc758995c4788c4b4d4dec54eef95fb8f38cb4d49c8fc7c (include.zip)
This release introduces a SAX interface to the library. While this may be a very special feature used by only few people, it allowed to unify all functions that consumed input and created some kind of JSON value. Internally, now all existing functions like parse
, accept
, from_cbor
, from_msgpack
, and from_ubjson
use the SAX interface with different event processors. This allowed to separate the input processing from the value generation. Furthermore, throwing an exception in case of a parse error is now optional and up to the event processor. Finally, the JSON parser is now non-recursive (meaning it does not use the call stack, but std::vector<bool>
to track the hierarchy of structured values) which allows to process nested input more efficiently.
Furthermore, the library finally is able to parse from wide string types. This is the first step toward opening the library from UTF-8 to UTF-16 and UTF-32.
This release further fixes several bugs in the library. All changes are backward-compatible.
std::wstring
, std::u16string
, and std::u32string
; the input will be converted to UTF-8 (#1031)std::string_view
when using C++17 (#1028)std::map
and std::unordered_map
from JSON if key type is not convertible to string; in these cases, values are serialized to arrays of pairs (#1079, #1089, #1133, #1138)nullptr_t
from JSON allowing to properly roundtrip null
values (#1169)items()
(#1045, #1134)std::swap
(#1168)key()
function for iterators returns a const reference rather than a string copy (#1098)float
as type for floating-point numbers (#1021)JSON_SKIP_UNSUPPORTED_COMPILER_CHECK
can skip the rejection of unsupported compilers - use at your own risk! (#1128)JSON_INTERNAL_CATCH
/JSON_INTERNAL_CATCH_USER
allows to control the behavior of exception handling inside the library (#1187)char
to JSON conversionstd::stringstream
(#1117)This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip) (115 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.2/json.hpp) (582 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.2/json.hpp.asc) (1 KB)
Release date: 2018-03-14 SHA-256: fbdfec4b4cf63b3b565d09f87e6c3c183bdd45c5be1864d3fcb338f6f02c1733 (json.hpp), 495362ee1b9d03d9526ba9ccf1b4a9c37691abe3a642ddbced13e5778c16660c (include.zip)
This release fixes several bugs in the library. All changes are backward-compatible.
basic_json
(e.g., using different template arguments for strings or objects) can now be used in assignments (#972, #977, #986).make clang_analyze
.This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.1/include.zip) (114 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.1/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.1/json.hpp) (577 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.1/json.hpp.asc) (1 KB)
Release date: 2018-02-13 SHA-256: e14ce5e33d6a2daf748026bd4947f3d9686ca4cfd53d10c3da46a0a9aceb7f2e (json.hpp), fde771d4b9e4f222965c00758a2bdd627d04fb7b59e09b7f3d1965abdc848505 (include.zip)
This release fixes several bugs in the library. All changes are backward-compatible.
0x7F
start byte.null
elements with a few bytes and the library did not check whether this size exceeded max_size()
.run_benchmarks
was added to quickly build and run the benchmark suite.#include <nlohmann/json.hpp>
to allow for selecting single_include
or include
or whatever installation folder as include directory.This release does not deprecate any functions. As an overview, the following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):
iterator_wrapper
are deprecated. Please use the member function items()
instead.friend std::istream& operator<<(basic_json&, std::istream&)
and friend std::ostream& operator>>(const basic_json&, std::ostream&)
are deprecated. Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.!!! summary “Files”
- [include.zip](https://github.com/nlohmann/json/releases/download/v3.1.0/include.zip) (114 KB) - [include.zip.asc](https://github.com/nlohmann/json/releases/download/v3.1.0/include.zip.asc) (1 KB) - [json.hpp](https://github.com/nlohmann/json/releases/download/v3.1.0/json.hpp) (577 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.1.0/json.hpp.asc) (1 KB)
Release date: 2018-02-01 SHA-256: d40f614d10a6e4e4e80dca9463da905285f20e93116c36d97d4dc1aa63d10ba4 (json.hpp), 2b7234fca394d1e27b7e017117ed80b7518fafbb4f4c13a7c069624f6f924673 (include.zip)
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.
merge_patch
for more information.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).include/nlohmann/json_fwd.hpp
to speed up compilation times (#314).benchmarks
folder, #921).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).yytext
any more as it could clash with macro definitions (#933).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).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):
friend std::istream& operator<<(basic_json&, std::istream&)
friend std::ostream& operator>>(const basic_json&, std::ostream&)
Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v3.0.1/json.hpp) (502 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.0.1/json.hpp.asc) (1 KB)
Release date: 2017-12-29 SHA-256: c9b3591f1bb94e723a0cd7be861733a3a555b234ef132be1e9027a0364118c4c
This release fixes small issues in the implementation of JSON Pointer and JSON Patch. All changes are backward-compatible.
10e2
are used.at(ptr)
function with JSON Pointers to list all possible exceptions (see #888).BUILD_TESTING
option (see #846, #885):fire: To unify the interfaces and to improve similarity with the STL, the following functions are deprecated since version 3.0.0 and will be removed in the next major version (i.e., 4.0.0):
friend std::istream& operator<<(basic_json&, std::istream&)
friend std::ostream& operator>>(const basic_json&, std::ostream&)
Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v3.0.0/json.hpp) (501 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v3.0.0/json.hpp.asc) (1 KB)
Release date: 2017-12-17 SHA-256: 076d4a0cb890a3c3d389c68421a11c3d77c64bd788e85d50f1b77ed252f2a462
After almost a year, here is finally a new release of JSON for Modern C++, and it is a major one! As we adhere to semantic versioning, this means the release includes some breaking changes, so please read the next section carefully before you update. But don't worry, we also added a few new features and put a lot of effort into fixing a lot of bugs and straighten out a few inconsistencies.
This section describes changes that change the public API of the library and may require changes in code using a previous version of the library. In section “Moving from 2.x.x to 3.0.0” at the end of the release notes, we describe in detail how existing code needs to be changed.
<stdexcept>
(#244). This not only allows to add more information to the exceptions (every exception now has an identifier, and parse errors contain the position of the error), but also to easily catch all library exceptions with a single catch(json::exception)
.json::type_error
exception during serialization (#838). The check for valid UTF-8 is realized with code from Björn Hoehrmann.null
(#388).<iostream>
, <ctype>
, and <stdexcept>
any more. You may need to add these headers to code relying on them.explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)
which was deprecated in version 2.0.0 (#480).To unify the interfaces and to improve similarity with the STL, the following functions are now deprecated and will be removed in the next major version (i.e., 4.0.0):
friend std::istream& operator<<(basic_json&, std::istream&)
friend std::ostream& operator>>(const basic_json&, std::ostream&)
Please use friend std::istream& operator>>(std::istream&, basic_json&)
and friend operator<<(std::ostream&, const basic_json&)
instead.
With all this breaking and deprecation out of the way, let's talk about features!
json::parse_error
is thrown which contains a detailed message on the error, but also a member byte
to indicate the byte offset in the input where the error occurred.accept
function returns a Boolean indicating whether the input is proper JSON. We also added a Boolean parameter allow_exceptions
to the existing parse
functions to return a discarded
value in case a syntax error occurs instead of throwing an exception.update
function was added to merge two JSON objects (#428). In case you are wondering: the name was inspired by Python.insert
function now also supports an iterator range to add elements to an object.dump
now has two optional parameters ensure_ascii
to escape all non-ASCII characters with \uxxxx
and an indent_char
parameter to choose whether to indent with spaces or tabs (#654).std::pair
and std::tuple
(#563, #614), enum
and enum class
(#545), std::vector<bool>
(#494). Fixed support for std::valarray
(#702), std::array
(#553), and std::map<std::string, std::string>
(#600, #607).Furthermore, there have been a lot of changes under the hood:
__builtin_expect
to optimize branch prediction as long as no error occurs.from_json
or to_json
function was not found for a user-defined type. We also added a debug visualizer nlohmann_json.natvis
for better debugging in MSVC (#844).JSON_Coverage
), compilation without exceptions (JSON_NoExceptions
), LLVM sanitizers (JSON_Sanitizer
), or execution with Valgrind (JSON_Valgrind
).There are five different exceptions inheriting from json::exception
:
json::parse_error
for syntax errors (including the binary formats),json::invalid_iterator
for errors related to iterators,json::type_error
for errors where functions were called with the wrong JSON type,json::out_of_range
for range errors, andjson::other_error
for miscellaneous errors.To support these exception, the try
/catch
blocks of your code need to be adjusted:
new exception | previous exception |
---|---|
parse_error.101 | invalid_argument |
parse_error.102 | invalid_argument |
parse_error.103 | invalid_argument |
parse_error.104 | invalid_argument |
parse_error.105 | invalid_argument |
parse_error.106 | domain_error |
parse_error.107 | domain_error |
parse_error.108 | domain_error |
parse_error.109 | invalid_argument |
parse_error.110 | out_of_range |
parse_error.111 | invalid_argument |
parse_error.112 | invalid_argument |
invalid_iterator.201 | domain_error |
invalid_iterator.202 | domain_error |
invalid_iterator.203 | domain_error |
invalid_iterator.204 | out_of_range |
invalid_iterator.205 | out_of_range |
invalid_iterator.206 | domain_error |
invalid_iterator.207 | domain_error |
invalid_iterator.208 | domain_error |
invalid_iterator.209 | domain_error |
invalid_iterator.210 | domain_error |
invalid_iterator.211 | domain_error |
invalid_iterator.212 | domain_error |
invalid_iterator.213 | domain_error |
invalid_iterator.214 | out_of_range |
type_error.301 | domain_error |
type_error.302 | domain_error |
type_error.303 | domain_error |
type_error.304 | domain_error |
type_error.305 | domain_error |
type_error.306 | domain_error |
type_error.307 | domain_error |
type_error.308 | domain_error |
type_error.309 | domain_error |
type_error.310 | domain_error |
type_error.311 | domain_error |
type_error.313 | domain_error |
type_error.314 | domain_error |
type_error.315 | domain_error |
out_of_range.401 | out_of_range |
out_of_range.402 | out_of_range |
out_of_range.403 | out_of_range |
out_of_range.404 | out_of_range |
out_of_range.405 | domain_error |
other_error.501 | domain_error |
If an overflow occurs during parsing a number from a JSON text, an exception json::out_of_range
is thrown so that the overflow is detected early and roundtripping is guaranteed.
NaN and INF floating-point values can be stored in a JSON value and are not replaced by null. That is, the basic_json class behaves like double
in this regard (no exception occurs). However, NaN and INF are serialized to null
.
Function explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)
should be replaced by the parse
function: Let ss
be a stream and cb
be a parse callback function.
Old code:
json j(ss, cb);
New code:
json j = json::parse(ss, cb);
If no callback function is used, also the following code works:
json j; j << ss;
or
json j; ss >> j;
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp) (437 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.1.1/json.hpp.asc) (1 KB)
Release date: 2017-02-25 SHA-256: faa2321beb1aa7416d035e7417fcfa59692ac3d8c202728f9bcc302e2d558f57
This release fixes a locale-related bug in the parser. To do so, the whole number handling (lexer, parser, and also the serialization) have been overworked. Furthermore, a lot of small changes added up that were added to this release. All changes are backward-compatible.
.
as decimal separator (e.g., the Norwegian locale nb_NO.UTF-8
) led to truncated number parsing or parse errors. The library now has been fixed to work with any locale. Note that .
is still the only valid decimal separator for JSON input.1.0
were correctly parsed as floating-point number, but serialized as integer (1
). Now, floating-point numbers correctly round trip.0123
) could yield a buffer overflow. This is fixed now by detecting such errors directly by the lexer.0
led to a comparison with null
. This is fixed now.-Weverything
(well, it needs -Wno-documentation-unknown-command
and -Wno-deprecated-declarations
, but you get the point).UINT8_MAX
which previously required defining a preprocessor macro for compilation.basic_json
.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.1.0/json.hpp) (426 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.1.0/json.hpp.asc) (1 KB)
This release introduces a means to convert from/to user-defined types. The release is backwards compatible.
to_json
and from_json
. Then, a conversion is as simple as putting a =
between variables. See the README for more information and examples.JSON_NOEXCEPTION
or by passing -fno-exceptions
to your compiler. In case the code would usually thrown an exception, abort()
is now called.meta()
which returns a JSON object with information on the version, compiler, and platform. See the documentation for an example.type_name()
is now public. It allows to query the type of a JSON value as string.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.10/json.hpp) (409 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.10/json.hpp.asc) (1 KB)
This release fixes several security-relevant bugs in the MessagePack and CBOR parsers. The fixes are backwards compatible.
find()
function to always return end()
when called on non-object value types.test/thirdparty
directory.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.9/json.hpp) (406 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.9/json.hpp.asc) (1 KB)
This release implements with CBOR and MessagePack two binary serialization/deserialization formats. It further contains some small fixes and improvements. The fixes are backwards compatible.
-Wdocumentation
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.8/json.hpp) (360 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.8/json.hpp.asc) (1 KB)
This release combines a lot of small fixes and improvements. The fixes are backwards compatible.
std::invalid_argument
is thrown)std::invalid_argument
is thrown)emplace
and emplace_back
have been added to JSON values and work as expecteddump
function)!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.7/json.hpp) (355 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.7/json.hpp.asc) (1 KB)
This release fixes a few bugs in the JSON parser found in the Parsing JSON is a Minefield 💣 article. The fixes are backwards compatible.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.6/json.hpp) (349 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.6/json.hpp.asc) (1 KB)
This release fixes the semantics of operator[]
for JSON Pointers (see below). This fix is backwards compatible.
operator[]
for JSON Pointers now behaves like the other versions of operator[]
and transforms null
values into objects or arrays if required. This allows to created nested structues like j["/foo/bar/2"] = 17
(yielding {"foo": "bar": [null, null, 17]}
) without problems.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.5/json.hpp) (347 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.5/json.hpp.asc) (1 KB)
This release fixes a regression bug in the stream parser (function parse()
and the <<
/>>
operators). This fix is backwards compatible.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.4/json.hpp) (347 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.4/json.hpp.asc) (1 KB)
This release fixes a bug in the stream parser (function parse()
and the <<
/>>
operators). This fix is backwards compatible.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.3/json.hpp) (347 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.3/json.hpp.asc) (1 KB)
This release combines a lot of small fixes and improvements. The release is backwards compatible.
char
, unsigned char
, uint8_t
). This includes all kind of string representations (string literals, char arrays, std::string
, const char*
), contiguous containers (C-style arrays, std::vector
, std::array
, std::valarray
, std::initializer_list
). User-defined containers providing random-access iterator access via std::begin
and std::end
can be used as well. See the documentation (1, 2, 3, 4) for more information. Note that contiguous storage cannot be checked at compile time; if any of the parse functions are called with a noncompliant container, the behavior is undefined and will most likely yield segmentation violation. The preconditions are enforced by an assertion unless the library is compiled with preprocessor symbol NDEBUG
.operator[]
for const JSON objects. The behavior of this const version of the operator is undefined if the given key does not exist in the JSON object, because unlike the non-const version, it cannot add a null
value at the given key. Assertions can be switched of by defining the preprocessor symbol NDEBUG
. See the documentation of assert
for more information.basic_json(std::istream&, const parser_callback_t)
has been deprecated and will be deleted with the next major release 3.0.0 to unify the interface of the library. Deserialization will be done by stream operators or by calling one of the parse
functions. That is, calls like json j(i);
for an input stream i
need to be replaced by json j = json::parse(i);
. Compilers will produce a deprecation warning if client code uses this function./Wall
now only warns about non-inlined functions (C4710) and the deprecation of the constructor from input-stream (C4996).make check
.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.2/json.hpp) (338 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.2/json.hpp.asc) (1 KB)
This release combines a lot of small fixes and improvements. The release is backwards compatible.
\x10
-\x1f
are not accepted any more.NDEBUG
, see the documentation of assert
.#error
command.get_ptr()
.sed
.std::all_of
, std::for_each
, or std::accumulate
. This facilitates reasoning about termination of loops and sometimes allowed to simplify functions to a single return statement.value()
function for JSON pointers (similar to at
function).std::cout
in the test cases.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.1/json.hpp) (321 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.1/json.hpp.asc) (1 KB)
This release fixes a performance regression in the JSON serialization (function dump()
). This fix is backwards compatible.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v2.0.0/json.hpp) (321 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v2.0.0/json.hpp.asc) (1 KB)
This release adds several features such as JSON Pointers, JSON Patch, or support for 64 bit unsigned integers. Furthermore, several (subtle) bugs have been fixed.
As noexcept
and constexpr
specifier have been added to several functions, the public API has effectively been changed in a (potential) non-backwards compatible manner. As we adhere to Semantic Versioning, this calls for a new major version, so say hello to 2️⃣.0️⃣.0️⃣.
uint64_t
(default value for template parameter NumberUnsignedType
) as data type for unsigned integer values. This type is used automatically when an unsigned number is parsed. Furthermore, constructors, conversion operators and an is_number_unsigned()
test have been added.at()
and operator[]
functions. Furthermore, JSON values can be “flattened” to key/value pairs using flatten()
where each key is a JSON Pointer. The original value can be restored by “unflattening” the flattened value using unflatten()
.diff(const basic_json&)
and applied with patch(const basic_json&)
. Note the created patches use a rather primitive algorithm so far and leave room for improvement..
) as decimal separator and ignores different settings from the locale.brew tap nlohmann/json && brew install nlohmann_json
.std::istream
(e.g., std::stringstream
or std::ifstream
).noexcept
specifier to basic_json(boolean_t)
, basic_json(const number_integer_t)
, basic_json(const int)
, basic_json(const number_float_t)
, iterator functions (begin()
, end()
, etc.)0.0
(vs. -0.0
) is preserved.std::move
.re2c
to version 0.16 to use a minimal DFAs for the lexer.is_number
, etc.) and const value access constexpr
.push_back
and operator+=
now work with key/value pairs passed as initializer list, e.g. j_object += {"key", 1}
.CMakeLists.txt
to make it easier to integrate the library into other projects.diff
function is rather primitive and does not create minimal diffs.iteration_wrapper
may change in the future and the function will be deprecated in the next release.!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v1.1.0/json.hpp) (257 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v1.1.0/json.hpp.asc) (1 KB)
This release fixes several small bugs and adds functionality in a backwards-compatible manner. Compared to the last version (1.0.0), the following changes have been made:
assert
is used, the assertions can be switched off by defining the preprocessor symbol NDEBUG
during compilation. [#168]get_ref()
. [#128, #184]operator[]
) now works with all kind of string representations. [#171, #189]There are still known open issues (#178, #187) which will be fixed in version 2.0.0. However, these fixes will require a small API change and will not be entirely backwards-compatible.
!!! summary “Files”
- [json.hpp](https://github.com/nlohmann/json/releases/download/v1.0.0/json.hpp) (243 KB) - [json.hpp.asc](https://github.com/nlohmann/json/releases/download/v1.0.0/json.hpp.asc) (1 KB)
This is the first official release. Compared to the prerelease version 1.0.0-rc1, only a few minor improvements have been made:
sprintf
is no longer used.iterator_wrapper
also works for const objects; note: the name may change!parse
function now also works with type std::istream&&
.value(key, default_value)
returns either a copy of an object's element at the specified key or a given default value if no element with the key exists.