You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change the default value of the CMake parameter JSON_MultipleHeader to ON to always use the multi-header version unless specified otherwise. CI: Enable 32bit unit test (3) #3532
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 is deprecated. Instead, pass two iterators; for instance, call basic_json::from_cbor(ptr, ptr+len) instead of basic_json::from_cbor({ptr, len}).
All deprecations are annotated with HEDLEY_DEPRECATED_FOR to report which function to use instead.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Release date: 2022-08-01
SHA-256: eb73896e9ce706ae6a62ce697dc8aca214840f70d8281779a6ea0cabe3afab3f (json.hpp), b4789050cacd110faf8b100cee82af19ad0b4d3249625f6582a60eeeb80c84a7 (include.zip), 5c8f7a4d9e9c0d565e71b6e5b0b3a12f784ffbf142e1ddc7ba86002cefb4c6ee (json.tar.xz)
Summary
Version 3.11.0 is one of the biggest releases (in terms of closed issues and merged pull requests) ever. It brings:
at
oroperator[]
), avoiding unnecessary allocations.<windows.h>
.All changes are backward-compatible.
💰 Note you can support this project via GitHub sponsors or PayPal.
✨ New Features
std::string_view
as object keys inat
,operator[]
,value
,erase
,find
,contains
, andcount
to avoid unnecessary allocations. Implement support for string_view (attempt no. 3) #3423, How can I use std::string_view as the json_key to "operator []" ? #1529, ordered_json doesn't accept keys of types other than string_t (e.g., string_view) #3558, Add overloads for more key types to ordered_map and fix ordered_map::erase(first, last) with first == last #3564🐛 Bug fixes
ordered_json
objects from initializer lists. switch from json to ordered_json #3342, switch from json to ordered_json #3343, Fix ordered_map ctor with initializer_list (fixes #3343) #3370operator<=>
. Tests failing when compiling with c++20 #3207, Fix C++20/gcc-12 issues (Part 2) #3446, Compilation with -fmodules-ts and use inside of a module #3472std::incrementable
. Iterator doesn't satisfy std::incrementable because post-increment may change constness #3331, Make iterator operator++/--(int) equality-preserving #3332std::any
from implicit conversion. Error occurred when converting nlohmann::json to std::any #3428, Exclude std::any from implicit conversion (fixes #3428) #3437from_json()
for strings. Deserialization: if class is_constructible from std::string wrong from_json overload is being selected, compilation failed #3171, Perplexing template deduction failure serialising a 3rd party type using base class #3267, Parse to custom class from unordered_json breaks on G++11.2.0 with C++20 #3312, Unit tests conversions & items fail to build (Clang <4.0/C++14 only) #3384, Fix constraints on from_json() for strings (fixes #3171, #3267, #3312, #3384) #3427, Parse to custom class from unordered_json breaks on G++11.2.0 with C++20 #3312, Starting with 3.10.4, just adding#include json.hpp
causes compile error: `overload resolution selected deleted operator '=' #3620<ranges>
and range-v3. Iterators cannot be used with range-v3 #3130, Fix C++20/gcc-12 issues (Part 2) #3446json
to behave likefloat
. Comparison of NaN differs between json and float #3409, Fix C++20/gcc-12 issues (Part 2) #3446operator<<(json_pointer)
to fix a regression after the 3.10.0 release. json_pointer__pop_back.cpp example does not compile #3600, Add operator<<(json_pointer) #3601value_type
detection to distinguish string types (was broken in releases 3.10.4, and 3.10.5). ambiguous regression #3204, Ambiguous conversion from nlohmann::basic_json<> to custom class. #3333, Re-add value_type detection to distinguish string types #3604, xwidgets doesn't compile with version >3.10.3 #3602, Add regression tests for #3204 and #3333 #3629⚡ Improvements
NLOHMANN_DEFINE_TYPE_INTRUSIVE
andNLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
. Allow default values for NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE #2819, Add macros NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT and ..._NON_INTRUSIVE_WITH_DEFAULT #3143meta
output for MSVC. Report the right __cplusplus value for MSVC in basic_json meta() #3417JSON_SKIP_LIBRARY_VERSION_CHECK
). Add check if different version is also included #3418json_pointer
on string type. Re-template json_pointer on string type #3415std::vector<bool>::reference
. Boolean value in array [is it possible?] #3533, Add to_json() for std::vector<bool>::reference #3534std::iterator_traits
to extractiterator_category
#3544patch_inplace
function to apply patches without copying. add patch_inplace function #3581, Clean up after #3581 #3596swap
by ADL to allow swapping with non-std
containers and improve error messages. Use swap() by ADL #3609NLOHMANN_JSON_NAMESPACE
) to avoid ODR errors when linking different versions of the library. Using versioned namespaces #1539, Mixing different JSON_DIAGNOSTICS settings in separately compiled units leads to core #3360, Multiple versions causing conflict #3588, Add versioned, ABI-tagged inline namespace and namespace macros #3590JSON_USE_GLOBAL_UDLS
) to avoid name clashes. Consider putting the user-defined literals in a namespace #1682, Move UDLs out of the global namespace #3605Warnings
-Wpragmas
warning in GCC <11. Use DOCTEST_* compiler macros and suppress pragmas warning #3550🔨 Further Changes
_MSC_VER
version to check forstd::filesystem
. fix _MSC_VER version to check for std::filesystem #3240<sstream>
dependency. Replace use of standard IO from error handling #3239, Remove stringstream #3244JSON_MultipleHeader
toON
to always use the multi-header version unless specified otherwise. CI: Enable 32bit unit test (3) #3532JSON_DISABLE_ENUM_SERIALIZATION
). Allow disabling default enum conversions #3536json.tar.xz
which can be used inFetchContent
. Add maintainer targets to create source archive #3289, Small release asset for CMake's FetchContent #3255CITATION.cff
. Fix CITATION.cff and add automatic validation of your citation metadata #3320.gitignore
. Ignore output directory #3572.pc
and.cmake
files toshare
directory. build: install .pc and .cmake files to share/ #3619CI
windows-latest
image. Fix and update CI #3368windows-2016
image. CI: windows-2016 has been deprecated; remove jobs #3416disabled_exceptions
unit test). Disable exceptions on ICPC #3621Unit tests
iterator_input_adapter
advances iterators correctly. Add unit test to make sure iterator_input_adapter advances iterators correctly #3548<windows.h>
. Add a unit test including windows.h #3631Documentation and examples
parse
andaccept
. Add a function that checks for valid json in a C++ string #3245, Improve documentation InputType and IteratorType #3246ordered_json
. Documentation forordered_json
should show proper use of theparse()
function. #3325, Add note on parsing ordered_json #3326FetchContent_MakeAvailable
in examples. Why not use FetchContent_MakeAvailable()? #3345, FetchContent_MakeAvailable #3351JSON_DIAGNOSTICS
in all linked objects. Mixing different JSON_DIAGNOSTICS settings in separately compiled units leads to core #3360, Add clarification to avoid misunderstanding that cause #3360 #3378FILE *
and add assertion. Add assertion if nullptr is passed to parse function #3593json
andordered_json
. ordered_json vs json types comparison #3443, Add documentation for comparing json and ordered_json #3599🔥 Deprecated functions
The implicit conversion from JSON Pointers to string (
json_pointer::operator string_t
) has been deprecated. Usejson_pointer::to_string
instead.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
is deprecated. Please use the member functionitems()
instead.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.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 is deprecated. Instead, pass two iterators; for instance, callbasic_json::from_cbor(ptr, ptr+len)
instead ofbasic_json::from_cbor({ptr, len})
.All deprecations are annotated with
HEDLEY_DEPRECATED_FOR
to report which function to use instead.This discussion was created from the release JSON for Modern C++ version 3.11.0.
Beta Was this translation helpful? Give feedback.
All reactions