Recent Releases of nlohmann-json

nlohmann-json - JSON for Modern C++ version 3.12.0

Release date: 2025-04-11 SHA-256: aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63 (json.hpp), b8cb0ef2dd7f57f18933997c9934bb1fa962594f701cd5a8d3c2c80541559372 (include.zip), 42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa (json.tar.xz)

Summary

This release fixes some bugs found in the 3.11.3 release and adds some new features.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

Key updates and enhancements

  • Diagnostic byte positions: A new macro, JSON_DIAGNOSTIC_POSITIONS, introduces member functions to query the byte positions of values in the input they were parsed from. When enabled, this information is also included in exceptions to help pinpoint errors. #4517 #4455 #4570 #4569 #4572 #4571 #4579 #4585 #4561
  • Enhanced conversion macros: The conversion macros for arbitrary types now include several upgrades:
    • All macros are templated, supporting json, ordered_json, and any other basic_json specialization. #4597 #2528 #4377 #2532 #2843 #3810 #4608
    • Derived classes can now be seamlessly converted to/from JSON using the new NLOHMANN_DEFINE_DERIVED_TYPE_* macros. #4033 #2199 #4562
  • Support for std::optional: The library now supports conversions from/to std::optional types when compiled with C++17. #1749 #4036
  • Flexible string compatibility: Functions patch, diff, and flatten now work with arbitrary string types. #4536 #4134 #4613 #4019
  • Binary format enhancements:
    • The BJData mapping now supports draft 3, including optimized binary array types. #4513 #4588
    • The BSON mapping has added support for unsigned 64-bit integers. #4590 #4535 #3894
    • The get_number function used in the binary format implementations has been optimized to read multiple bytes at once. #4391
  • Multidimensional array conversion: Multidimensional C-style arrays can now be directly converted to JSON. #4262 #4248
  • Filesystem paths in UTF-8: The conversions from/to std::filesystem::path are now encoded to UTF-8 strings by default on all operating systems. #4271 #4631
  • CMake 4.0 support. By adjusting the CMake minimal version to 3.5, CMake 4.0 can be used without warning or error. #4709

Changes and fixes

  • The iteration_proxy is now a std::forward_iterator instead of just an std::input_iterator. This allows more use cases when items() is fed into C++20 std::views. The iterator always satisfied all requirements for a forward iterator, but was exposed as only an input iterator by the used iterator tag. #4371 #4372
  • Fix the conversion from enums with unsigned underlying type to JSON. #4236 #4237
  • Fix GDB pretty printer which was broken since m_data added. #4343 #4309
  • Update natvis to reflect 3.11.3 and the current structure of basic_json. #4451 #4438 #4438
  • Fix crash when passing nullptr to parse function expecting FILE*. Instead, now an exception is thrown. #4485 #4487
  • Fix number parsing such that integers are not parsed to float when EINTR set in errno. #4506
  • Fix SAX output of number_float to be locale-independent. #4505 #4084
  • Fix iterators to allow comparing default-initialized iterators. #4512 #4493
  • Fix return value of get_ptr for unsigned integers. #4525 #4475
  • Fix regression of #2755 and replace EOF with char_traits. #4532
  • Fix extended diagnostics to not trigger an assertion. #4537 #3915
  • Fix NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT throw an exception with an empty json #4507 #4508
  • Modernize integer comparison. #4577 #4559
  • Serialize empty tuple into [] instead of null. #4594 #4530

Warnings

The quality assurance page gives an overview of the warning flags used during the tests.

Compiler warnings

  • Suppress weak-vtables warning for exceptions. #4500 #4087
  • Add 40+ GCC warning flags for GCC 14.2.0. #4524
  • Fix ignored attribute warning during build. #4670
  • Add explanation for suppressed CodeQL issues. #4362 #4361
  • Move compiler flags to separate CMake files (GCC, Clang). #4560

Clang-Tidy

  • Suppress warnings modernize-use-std-numbers, readability-redundant-member-init, and bugprone-unused-local-non-trivial-variable. #4276
  • Suppress warnings modernize-type-traits and modernize-avoid-c-arrays in NLOHMANN_JSON_SERIALIZE_ENUM. #4497 #3924
  • Suppress warning boost-use-ranges as we do not want to rely on Boost. #4489
  • Suppress warning modernize-use-designated-initializers as designated initializers are a C++20 feature. #4489
  • Suppress warning modernize-use-ranges as ranges are a C++20 feature. #4489
  • Suppress warning clang-analyzer-webkit.NoUncountedMemberChecker as we are using pointers internally. #4701
  • Fix warning modernize-use-integer-sign-comparison. #4558

Build

CMake

  • Adjust CMake minimal version to 3.5. #4709
  • Allow overriding the CMake target name via variable NLOHMANN_JSON_TARGET_NAME. #4483
  • Add CPack support. #4459
  • Adjust CMake to generate a pkg-config file that follows the pkg-config conventions. #4456

Package Managers

  • Remove alwayslink=True Bazel flag. #4396
  • Improve Bazel support by switching to Bzlmod. #4584
  • Add VisionOS support to Swift Package Manager Package.swift definition file. #4611
  • Remove wsjcpp package manager support. #4623

CI

Tests

  • Add test for libstdc++. #4495
  • Skip enum tests when JSON_DisableEnumSerialization=ON. #4504 #4384
  • Add a build step to build the documentation. #4549
  • Fix the coverage job. #4595
  • Add comment on reproducible builds. #4494 #4496

Infrastructure

  • Remove unsupported macos-11 image; the following Xcode versions are no longer tested in the CI: '11.7', '12.4', '12.5.1', '13.0'. #4489
  • Add macos-13 image to test Xcode versions '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2'. #4489
  • Add macos-14 image to test Xcode versions '15.3', '15.4'. #4489
  • Add macos-15 image to test Xcode versions '16.0', '16.1'. #4489
  • Test GCC versions '4.8', '4.9', '5', '6' on json-ci image as these versions are no longer work on the respective gcc images (checkout fails). #4489
  • Add tests for GCC versions '13', '14'. #4489
  • Add tests for Clang versions '16', '17', '18', '19'. #4489
  • Update README with a table of compilers/OS used in the CI. #4489
  • Apply security best practices by StepSecurity. #4539 #4546 #4058 #4547 #4550 #4551
  • Use Dependabot to automatically update GitHub actions and Python tools used in the CI. #4489 #4541 #4540 #4543 #4544 #4545 #4542 #4548 #4557 #4567 #4600 #4601 #4602 #4603 #4604 #4615 #4614 #4616 #4617 #4620 #4624 #4625 #4634 #4635 #4646 #4648 #4652 #4659 #4661 #4664 #4665 #4668 #4672 #4680 #4683 #4688 #4689 #4695 #4697 #4698 #4700 #4707 #4711 #4715 #4716 #4718 #4719 #4726
  • Use ubuntu-latest image to run Valgrind. #4575
  • Use Clang image to run iwyu. #4574
  • Adjust permissions in workflows. #4553
  • Use Python to install cppcheck. #4553
  • Move requirements.txt files for cppcheck, cpplint, and reuse to central location. #4553
  • Adjust cppcheck call. #4553
  • Add code exclusions to source files. #4553
  • Migrate stalebot to GitHub action. #4560
  • Remove deprecated .lgtm.yml file. #4560
  • Add CI steps for C++26. #4560
  • Add Xcode 16.2 (macOS) and Clang 3.4 (Ubuntu) action. #4560
  • Simplify Ubuntu workflow to use ubuntu-latest more often and reduce dependencies to more exotic containers. #4560
  • Add DCO requirement: all commits since January 17, 2025, need to be signed off. #4560
  • Remove .pre-commit-config.yml file. #4560
  • Pull update for tests/thirdparty/imapdl/filterbr.py. #4560
  • Make gdb-pretty-printer work with older Python versions. #4691 #4693
  • Update the REUSE integration. #4521

Indentation and amalgamation

  • Adjust and modernize flags for Artistic Style. #4277 #4275 #4573
  • Fix deprecation warning in amalgamation CI check. #4227

Documentation

The documentation website contains all project documentation.

Fixed documentation

  • Fix version history. #4269 #4310 #4307 #4310
  • Remove broken link in Contribution Guidelines. #4274 #4486
  • Fix custom data source example in README. #4335
  • Fix an example to catch an exception by reference. #4331
  • Fix example for JSON Pointer usage. #4255
  • Fix using a wrong function in documentation. #4472
  • Fix for incorrect function name in a documentation example. #4342 #4334
  • Fix typos. #4345 #4412 #4565 #4679 #4723
  • Fix style warnings. #4516
  • Fix broken links. #4516 #4560 #4605
  • Fix ci_test_api_documentation CI step. #4516
  • Remove duplicate documentation files. #4560
  • Fix the index file for mkdocs after merging. #4517
  • Fix duplicate keys in navigation. #4560
  • Add missing macros in README and link to docs for more info. #4582 #4260
  • Fix documentation for macros to show correct names. #4564

Added documentation

Improved documentation

  • Update navigation. #4516
  • Extend documentation of parse and accept with respect to #4485 #4487 #4516
  • Update code of conduct. #4560
  • Update contribution guidelines. #4560
  • Update pull request template. #4560
  • Update security policy. #4560
  • Update docset table of contents. #4560
  • Overwork documentation of all serialization macros (cross references, decision table, removed redundancies). #4560
  • Shorten README serialization macro section. #4560
  • Document the compilers used in the CI. #4560
  • Add a quick reference to README. #4560
  • Bump the copyright years. #4606

Package Manager documentation

  • Extend the documentation of package managers with more examples. #4516
  • Move package manager section to documentation. #4560
  • Add Swift Package Manager and xmake. #4560
  • Add an example for Conda. #4560
  • Add an overview with logos. #4560
  • Annotate Buckaroo, CocoaPods, and wsjcpp as outdated. #4560

Documentation implementation

  • Replace PlantUML by Mermaid. #4026
  • Serve assets (fonts, CSS) locally. #4560
  • Update Python requirements. #4516

- C++
Published by nlohmann about 1 year ago

nlohmann-json - JSON for Modern C++ version 3.11.3

Release date: 2023-11-28 SHA-256: 9bea4c8066ef4a1c206b2be5a36302f8926f7fdc6087af5d20b417d0cf103ea6 (json.hpp), a22461d13119ac5c78f205d3df1db13403e58ce1bb1794edc9313677313f4a9d (include.zip), d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d (json.tar.xz)

Summary

This release fixes some bugs found in the 3.11.2 release.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:sparkles: New Features

  • Allow custom base class as node customization point. This adds an additional template parameter which allows to set a custom base class for nlohmann::json. This class serves as an extension point and allows to add functionality to json node. Examples for such functionality might be metadata or additional member functions (e.g., visitors) or other application specific code. By default the parameter is set to void and an empty base class is used. In this case the library behaves as it already did. #3110
  • Add more specific parse error message when attempting to parse empty input. #4037 #4180
  • Add serialization-only user defined type macros (NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE and NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE). #3816
  • Add Bazel build support. If you are using Bazel you can simply reference this repository using http_archive or git_repository and depend on @nlohmann_json//:json. #3709
  • Support Apple's Swift Package Manager. #4010

:bug: Bug Fixes

  • Adjust CMake files to accept NEW CMake policies up to CMake 3.14. This fixes a nasty deprecation warning that "Compatibility with CMake < 3.5 will be removed from a future version of CMake". #4076 #4112
  • Fix CMake header path in install with custom CMAKE_INSTALL_INCLUDEDIR. #4194
  • Add missing <numeric> header include. #3717 #3718 #3719
  • Replace uses of INT_MIN/INT_MAX, etc. with std::numeric_limits and consistently use std-namespaced integer types to make library work with never GCC versions. #3722 #3723
  • Add missing files (json_fwd.hpp and Bazel build files) to release artifact include.zip. #3727 #3728
  • Fix 'declaration hides global declaration' warning. #3751
  • Fix natvis XML. #3858 #3863
  • Fix warning about moved from object. #3805 #3889
  • Remove a magic number to fix a warning. #3837 #3888
  • Fix debug pretty-printer by checking if match is valid before accessing group. #3919 #3920
  • Fix custom allocators by defining missing rebind type. #3895 #3927
  • Prevent memory leak when exception is thrown in adl_serializer::to_json #3881 #3901
  • Fix Clang-Tidy warnings. #4047
  • Fix init-list construction when size_type is not int. #4140
  • Fix deprecation warning "identifier _json preceded by whitespace in a literal operator declaration". #4129 #4161
  • Fix compile error with _HAS_STATIC_RTTI=0. #4046
  • Fix chartraits deprecation warning "`chartraitsis deprecated:chartraitsforTnot equal tochar,wchart,char8t,char16torchar32_t` is non-standard". #4163 #4179

:hammer: Further Changes

CI

  • Use official Clang/GCC Docker containers in the CI. #3703
  • Add workflow to check if the source files area amalgamated. #3693
  • Fix CI build. #3724 #3862 #3978 #3985 #4025 #4083 #4160 #4196 #4215
  • Use Clang 15. #3822 #3876
  • Add CIFuzz CI GitHub action. #3845
  • Fix MinGW script and CI. #3892 #4175
  • Removed lgtm and DroneCI and added Cirrus CI. #3890 #3906 #3935 #3937
  • Set minimal permissions to Github Workflows. #3971 #3972
  • Refactor amalgamation workflow to avoid dangerous use of pullrequesttarget. #3945 #3969

Documentation

  • Add migration guide to replace deprecated library functions. #3702 #3887
  • Add dark mode toggle to documentation #3726
  • Fix typos in documentation. #3748 #3767 #3902 #3932 #3951 #4109 #4126 #4143 #4149 #4159 #4173
  • Update Codacy link. #3740
  • Bump documentation tool versions. #3781 #3872 #3891 #3934
  • Add vcpkg port version badge. #3988
  • Add to CONTRIBUTING.md that make pretty is required for test updates. #4045
  • Use template get instead of get in examples. #3827 #4038 #4039
  • Capture exceptions by const& in docs. #4099
  • Fix source highlighting in user defined type macros docs. #4169

Tests

  • Use std::ranges::equals for range comparisons in test case. #3927 #3950
  • Add more algorithm tests to unit-algorithm.cpp. #4044

:fire: Deprecated functions

This release does not deprecate any function. See the migration guide for help adjusting your code for future versions.

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.

- C++
Published by nlohmann over 2 years ago

nlohmann-json - JSON for Modern C++ version 3.11.2

Release date: 2022-08-12 SHA-256: 665fa14b8af3837966949e8eb0052d583e2ac105d3438baba9951785512cf921 (json.hpp), e5c7a9f49a16814be27e4ed0ee900ecd0092bfb7dbfca65b5a421b774dccaaed (include.zip), 8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f (json.tar.xz)

Summary

This release fixes some bugs found in the 3.11.1 release. Furthermore, the of the namespace library has been re-structured.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug Fixes

  • Fix the value function which was broken for strings, size types, and nullptr in release 3.11.0. #3652 #3655 #3663
  • Fix the json_fwd.hpp header to be self-contained and add it to the single-header release. #3656 #3679 #3687
  • Fix regression that broke using json_pointer as key in associative containers. #3680 #3685
  • Add missing constraint to deprecated JSON Pointer overloads of contains and at. #3658 #3681
  • Fix comparison between json_pointer and strings with == and !=. These comparisons worked in 3.10.5, but were broken in 3.11.0 and 3.11.1. #3654 #3664
  • Fix to_json conversion of std::vector<bool>::reference and std::vector<bool>::const_reference for STLs where these are the same as basic_json::boolean_t& and basic_json::boolean_t, respectively. #3677 #3678

:zap: Improvements

  • Restructure inline namespace and allow version component to be disabled. See documentation. #3683 #3696 #3697 #3698
  • Avoid heap allocations in BJData parser. #3637

:hammer: Further Changes

Documentation

  • Publish documentation on every push to develop branch. #3660 #3673
  • Add missing examples for the public API. #3672 #3686
  • Fix typo in json_pointer documentation. #3692

Community

  • Add a badge for the Discord chat to the README file. The goal of that additional communication channel beyond the existing ones is to quickly coordinate between the contributors. #3651
  • Complete contributor list. #3662 #3670

CI

  • Remove the macos-10.15 image from the CI as it is removed by GitHub Actions. #3612 #3615 #3626
  • Remove hardcoded paths in Ubuntu workflow. #3626
  • Only trigger AppVeyor builds if relevant files have been changed. #3626
  • Fix CodeQL warning. #3626
  • Harmonize naming of GitHub Actions jobs. #3661
  • Add labeler action to automatically add PR labels based on the changed files. #3671 #3674 #3675
  • Lint API documentation in the CI. #3672
  • Add local LGTM configuration and suppress warnings on third-party scripts. #3643

:fire: Deprecated functions

The following functions have been deprecated in earlier versions and will be removed in the next major version (i.e., 4.0.0):

  • The function iterator_wrapper is deprecated. Please use the member function items() instead.
  • Functions 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.
  • 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}).
  • The implicit conversion from JSON Pointers to string (json_pointer::operator string_t) is deprecated. Use json_pointer::to_string instead.

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

- C++
Published by nlohmann almost 4 years ago

nlohmann-json - JSON for Modern C++ version 3.11.1

Release date: 2022-08-01 SHA-256: 9279dc616aac67efce68967f118051b50236612b90572e059783d368bd78687e (json.hpp), 9c15ca7806f863872452bfbc85fee6d1c9868117e3ea5e00a204ae961a2e1ae7 (include.zip), e6dd39f8f2da9cab11de2212acdd40b1cc1aafbe09da8c92933b911d19da3302 (json.tar.xz)

Known issues

  • #3652 Regression: call to member function 'value' is ambiguous
  • #3654 Regression: no match for 'operator!=' comparing jsonpointer and const char */stringt
  • #3655 Regression: .value is compilation error

All issues are fixed in the develop branch and will be part of the 3.11.2 release.

Summary

Version 3.11.0 moved the user-defined string literals (UDL) into namespace nlohmann::literals::json_literals (see documentation). Unfortunately, this namespace was not imported to the global namespace by default which broke code. This release fixes this bug.

All changes are backward-compatible. See release notes of version 3.11.0 for more information on other features.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug fixes

  • Set default value of JSON_USE_GLOBAL_UDLS and the CMake options JSON_GlobalUDLs to 1 to import the user-defined string literals from the nlohmann::literals::json_literals namespace into the global namespace by default. #3644 #3645 #3646

- C++
Published by nlohmann almost 4 years ago

nlohmann-json - JSON for Modern C++ version 3.11.0


:bug: Unfortunately, this release introduced a bug that breaks existing usages of the user-defined string literals (UDL). This is fixed in version 3.11.1.


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:

  • String view support for all functions working on object keys (e.g., at or operator[]), avoiding unnecessary allocations.
  • BJData as the fifth supported binary format besides BSON, CBOR, MessagePack, and UBJSON.
  • Better C++20 support to make the library integrate more smoothly with newer codebases.
  • Better support for avoiding problems when multiple versions of the library are used in the same project.
  • Even better and more extensive documentation and examples.
  • More tests for edge cases like 32-bit support, C++20 features, using the library with ICPC, or after including <windows.h>.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:sparkles: New Features

  • Allow to use std::string_view as object keys in at, operator[], value, erase, find, contains, and count to avoid unnecessary allocations. #3423, #1529, #3558, #3564
  • Add support to read and write the UBJSON-derived Binary JData (BJData) format (see documentation). #3336, #3461, #3463, #3475, #3479, #3493, #3491, #3492, #3490, #3500, #3502, #3503, #3505, #3513, #3514, #3519, #3523, #3541, #3543

:bug: Bug fixes

  • Allow creation of ordered_json objects from initializer lists. #3342, #3343, #3370
  • Fix failing tests when compiling with C++20 and add support for operator<=>. #3207, #3446, #3472
  • Fix comparison-related compilation problems in C++20 on GCC 12. #3138, #3379
  • Make iterator satisfy std::incrementable. #3331, #3332
  • Exclude std::any from implicit conversion. #3428, #3437
  • Fix constraints on from_json() for strings. #3171, #3267, #3312, #3384, #3427, #3312, #3620
  • Make iterators usable with <ranges> and range-v3. #3130, #3446
  • Fix comparison of NaN values with json to behave like float. #3409, #3446
  • Add operator<<(json_pointer) to fix a regression after the 3.10.0 release. #3600, #3601
  • Fix JSON Patch to not create missing parent objects. #3134, #3199, #3628
  • Re-add value_type detection to distinguish string types (was broken in releases 3.10.4, and 3.10.5). #3204, #3333, #3604, #3602, #3629
  • Fix latest build error in MSVC platform (was broken during development of 3.11.0). #3630

:zap: Improvements

  • Allow default values for NLOHMANN_DEFINE_TYPE_INTRUSIVE and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE. #2819, #3143
  • Avoid clash with Arduino defines. #3338
  • Improve meta output for MSVC. #3417
  • Check and warn if a different version of the library is already included (see JSON_SKIP_LIBRARY_VERSION_CHECK). #3418
  • Re-template json_pointer on string type. #3415
  • Allow to create booleans from std::vector<bool>::reference. #3533, #3534
  • Allow to use array types where iterators are pointers. #3544
  • Improve performance of writing binary formats to byte vectors. #3569
  • Add patch_inplace function to apply patches without copying. #3581, #3596
  • Use swap by ADL to allow swapping with non-std containers and improve error messages. #3609
  • Add versioned, ABI-tagged inline namespace (see NLOHMANN_JSON_NAMESPACE) to avoid ODR errors when linking different versions of the library. #1539, #3360, #3588, #3590
  • Move UDLs out of the global namespace (see JSON_USE_GLOBAL_UDLS) to avoid name clashes. #1682, #3605

Warnings

  • Fix ICPC warning 1098. #3632, #3634
  • Fix a -Wpragmas warning in GCC <11. #3550

:hammer: Further Changes

  • Fix _MSC_VER version to check for std::filesystem. #3240
  • Remove <sstream> dependency. #3239, #3244
  • Overwork bug template to systematically request information. #3348
  • Add script to test local version in Compiler Explorer. #3456
  • Change the default value of the CMake parameter JSON_MultipleHeader to ON to always use the multi-header version unless specified otherwise. #3532
  • Add option to disable default enum conversions (see JSON_DISABLE_ENUM_SERIALIZATION). #3536
  • Add maintainer targets to create source archive json.tar.xz which can be used in FetchContent. #3289, #3255
  • Fix CITATION.cff. #3320
  • Use The Pitchfork Layout (PFL). #3462
  • Update Cpplint. #3454
  • More intermediate folders from Visual Studio Code are added to .gitignore. #3572
  • Add badge for https://repology.org/project/nlohmann-json/versions. #3586
  • Use REUSE licensing framework. #3546 , #3633, #3635
  • Install .pc and .cmake files to share directory. #3619

CI

  • Add support for Visual Studio 2022., #3295
  • Adjust GitHub Actions CI wrt. windows-latest image. #3368
  • Remove deprecated windows-2016 image. #3416
  • Speed up AppVeyor CI. #3422
  • Update CI image to check with ICPC, GCC 11 and Clang 14. #3420
  • Add build step for ICPC to CI. #3465
  • Add more Xcode versions (13.3.1, 13.3, 13.2.1, 13.2, and 13.1) to the CI. #3485
  • Fix "JSON_MultipleHeaders" option spelling in CI. #3555
  • Increase timeout for Unicode tests. #3579, #3580, #3614
  • Abort CI runs on newer commits on the same branch. #3610
  • Fix MinGW CI failures. #3618
  • Disable exceptions on ICPC (for the disabled_exceptions unit test). #3621

Unit tests

  • Improve unit tests. #3380, #3393, #3365, #3405, #3377, #3421, #3422
  • Disable regression test on GCC <8.4. #3451
  • Add tests for 32 bit. #3524, #3529, #3530, #3532
  • Add error message if test suite cannot be found. #3584, #3585
  • Add unit test to make sure iterator_input_adapter advances iterators correctly. #3548
  • Add a unit test including <windows.h>. #3631

Documentation and examples

  • Add more examples to documentation. #3464
  • Improve documentation on supported types of parse and accept. #3245, #3246
  • Add documentation on how to parse JSON Lines input. #3247
  • Fix typos. #3249, #3265, #3426, #3439, #3481, #3499
  • Document parsing to ordered_json. #3325, #3326
  • Use FetchContent_MakeAvailable in examples. #3345, #3351
  • Document requirement of using the same definition of JSON_DIAGNOSTICS in all linked objects. #3360, #3378
  • Document fuzz testing. #3477, #3478
  • Add documentation of macros and runtime assertions. #3444, #3431
  • Fix documentation of JSON Pointer. #3511, #3520
  • Make certain usage patterns more prominent in the README. #3557
  • Document precondition for parsing from FILE * and add assertion. #3593
  • Improve documentation. #3592
  • Add documentation for comparing json and ordered_json. #3443, #3599
  • Adjust JSON Pointer examples and add CI step for the examples. #3622
  • Overwork documentation and add more examples. #3553

:fire: Deprecated functions

The implicit conversion from JSON Pointers to string (json_pointer::operator string_t) has been deprecated. Use json_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):

  • The function iterator_wrapper is deprecated. Please use the member function items() instead.
  • Functions 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.
  • 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.

- C++
Published by nlohmann almost 4 years ago

nlohmann-json - JSON for Modern C++ version 3.10.5

Release date: 2022-01-03 SHA-256: e832d339d9e0c042e7dff807754769d778cf5d6ae9730ce21eed56de99cb5e86 (json.hpp), b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e (include.zip)

Summary

The previous version 3.10.4 introduced support to convert std::filesystem objects to JSON and vice versa. Unfortunately, we made the assumption that any compiler supporting C++17 would also have proper filesystem support. This was a mistake. This release introduces preprocessor checks (and means to override them) to make sure that the conversion support is only compiled if the compiler is detected to support it.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug fixes

  • Make sure C++17 filesystem conversions are only used if the compiler supports it. Furthermore, add defines JSON_HAS_FILESYSTEM and JSON_HAS_EXPERIMENTAL_FILESYSTEM which can be set to 0 to avoid using filesystem support altogether.std::filesystem. #3090 #3097 #3101 #3156 #3203
  • Fix a compilation error with Nvidia CUDA Compiler (NVCC). #3013 #3234

Warnings

  • Fix a warning for shadowed variables. #3188 #3193
  • Fix a warning on a pointless comparison. #3227 #2712 #2676 #1390 #755

:zap: Improvements

  • Add a parameter to the update function to recursively merge objects with common keys. #3006 #3069
  • Extend std::hash and std::swap to work on any nlohmann::basic_json specializations rather than just nlohmann::json. #3121

:hammer: Further Changes

Tests and CI

  • Update CI to use Clang 14, GCC 6, and Clang-Tidy 14. #3088
  • Update cpplint. #3225
  • Add build step for the Nvidia CUDA Compiler (NVCC). #3227
  • Remove Travis CI. #3087 #3233
  • Compile and execute the test suite with C++17. #3101

Documentation

  • The mkdocs-based documentation in doc/mkdocs has been totally overworked. It now has a unified structure, more examples, and contains all information from the previous Doxygen-based documentation. The single source of truth is now the documentation on https://json.nlohmann.me and in particular the API Documentation. #3071
  • Removed Wandbox online examples. #3071
  • Fix typos, links, and parameter names in the documentation. #3102 #3125 #3140 #3145 #3148
  • Add more examples. #3071 #3100

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann over 4 years ago

nlohmann-json - JSON for Modern C++ version 3.10.4

Release date: 2021-10-16 SHA-256: c9ac7589260f36ea7016d4d51a6c95809803298c7caec9f55830a0214c5f9140 (json.hpp), 62c585468054e2d8e7c2759c0d990fd339d13be988577699366fe195162d16cb (include.zip)

Summary

This release fixes two bugs introduced in release 3.10.0 and fixes the conversion of std::filesystem::path. All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug Fixes

  • Fix regression bug introduced in release 3.10.0 which broke compilation for types with an explicit default constructor with default arguments. #3077 #3079
  • Fix regression bug introduced in release 3.10.0 which treated the return values of std::find and std::remove as pointers which could break compilation. #3081 #3082
  • Fix converting std::filesystem::path to JSON. Before release 3.10.3, such a conversion would trigger a stack overflow. Release 3.10.3 then further broke compilation on Windows. #3070 #3073

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann over 4 years ago

nlohmann-json - JSON for Modern C++ version 3.10.3

Release date: 2021-10-08 SHA-256: bac28658a4c9410faa55960a70c1ac541e8a51bbaae57dc395e23ca5abd3159a (json.hpp), 4ae5744bc1edd216c79f619fd49915c0e490e41b05434c2d2b89e078299f04ed (include.zip)

Summary

This release fixes two more bug introduced in release 3.10.0: the extended diagnostics triggered assertions when used with update() or when inserting elements into arrays. All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug Fixes

  • Fix bug in the update() function when used with extended diagnostics. #3007 #3008
  • Fix bug when inserting into arrays when using extended diagnostics. #2926 #3032 #3037

:zap: Improvements

Binary formats

  • Custom allocators are now supported when writing binary formats (e.g., CBOR, MessagePack) into a std::vector. #2982 #2989

User-defined type support

  • Allow conversion from types that do not define an explicit iterator type, but have a begin() and end() function. #3020

Tests and CI

  • Updated the Docker image used in the CI. #2981 #2986
  • Corrected the compiler version mentioned in the README file. #3040

Documentation

  • Add script to generate docset for Dash, Velocity, and Zeal. #2967

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann over 4 years ago

nlohmann-json - JSON for Modern C++ version 3.10.2

Release date: 2021-08-26 SHA-256: 059743e48b37e41579ee3a92e82e984bfa0d2a9a2b20b175d04db8089f46f047 (json.hpp), 61e605be15e88deeac4582aaf01c09d616f8302edde7adcaba9261ddc3b4ceca (include.zip)

Summary

This release is made days after the 3.10.1 release due to a bug in the release script: The 3.10.1 release at GitHub contained the correct files, but the associated tag v3.10.1 points to the wrong commit. This release is made with a fixed build script. All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:zap: Improvements

  • Fix the release scripts to correctly tag releases. #2973
  • Fix some -Wunused warnings on JSON_DIAGNOSTICS when the library is built without CMake. #2975 #2976

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann almost 5 years ago

nlohmann-json - JSON for Modern C++ version 3.10.1

Release date: 2021-08-24 SHA-256: 0b628af78a2f0f3e2ff41d8dfa18314dd53831ffc2720c2944192d9f53727f4d (json.hpp), 144268f7f85afb0f0fbea7c796723c849724c975f9108ffdadde9ecedaa5f0b1 (include.zip)

Summary

This release fixes a bug introduced in release 3.10.0: the extended diagnostics triggered an assertion when used with ordered_json. All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug Fixes

  • Fix an assertion triggered in the extended diagnostics using ordered_json. #2962 #2963
  • Make GDB pretty-printer robust against unset variable names. #2950

:zap: Improvements

Warnings

  • Add a missing header to hash.hpp. #2948
  • Fix some -Wextra-semi-stmt warnings. #2957

Tests and CI

  • Avoid duplicate builds in AppVeyor. #2952
  • Remove an outdated test binary that is not supported any longer. #2941 #2945
  • Skip tests that would fail if CMake option JSON_Install is set to OFF. #2946 #2947
  • Move Travis jobs to travis-ci.com. #2938 #2959
  • Set stack size for some unit tests when building with MSVC. #2955 #2961
  • Add a regression test. #2960

Documentation

  • Update the Homebrew command as nlohmann-json is now in homebrew-core. #2943 #2966
  • Add example for integration via vcpkg. #2944 #2954
  • Fix a typo in the documentation. #2968

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann almost 5 years ago

nlohmann-json - JSON for Modern C++ version 3.10.0

Release date: 2021-08-17 SHA-256: 230f3a03cefd586661ebab577a347c973d97a770afb89e22c52abc3c2a19d0a7 (json.hpp), b5e3bfad07feba218a26a4f809fbb0d1e33450524bf5d7244cabc92cf8178c69 (include.zip)

Summary

JSON for Modern C++ 3.10.0 is the first release for over a year. It contains some new features and a lot of minor changes and bug fixes.

Most notably, it introduces extended diagnostics. By defining JSON_DIAGNOSTICS before including the json.hpp, a JSON Pointer is added to exceptions which helps to debug issues with object access, array indices, or mismatching types.

Another important change behind the curtains is a fully overworked CI which performs a lot of checks for every commit which should allow more frequent releases in the future.

All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:sparkles: New Features

  • Add extended diagnostics information by adding a JSON Pointer to the exception messages indicating the exact location of a invalid type errors or out-of-bound errors.

    [json.exception.type_error.302] (/address/housenumber) type must be number, but is string

    Exceptions in the library are thrown in the local context of the JSON value they are detected. This makes detailed diagnostics messages, and hence debugging, difficult. To create better diagnostics messages, each JSON value needs a pointer to its parent value such that a global context (i.e., a path from the root value to the value that lead to the exception) can be created. That global context is then provided as a JSON Pointer.

    As this global context comes at the price of storing one additional pointer per JSON value and runtime overhead to maintain the parent relation, extended diagnostics are disabled by default. They can, however, be enabled by defining the preprocessor symbol JSON_DIAGNOSTICS to 1 before including json.hpp. See the documentation for more information. #932 #1508 #2562 #2838 #2866

  • Add a GDB pretty printer to facilitate reading basic_json values in GDB. #1952 #2607

  • Add a new value store to the cbortaghandler_t which allows to store the tags of CBOR values as binary subtypes. #2863 #2908

  • Add support for containers with non-default-constructible types. #2574 #2576

:bug: Bug Fixes

  • Fix a regression bug that failed ordered_json to be used when exceptions were switched off. #2347 #2725 #2934
  • Added iterator range insertion for ordered_json. #2490 #2512
  • Change the type of binary subtypes to std::uint64_t to support subtypes >255. Furthermore, the return value of the subtype() function has been fixed to the documented value -1 in case no subtype is given. #2863 #2908
  • Fix move constructor of internal json_ref type which created null values when compiled with -fno-elide-constructors. #2387 #2405
  • Fix the compilation of input_adapter for containers in edge cases. #2553
  • Allow parsing from std::byte containers. #2413 #2546 #2550 #2602 #2869
  • Fix memory leak in to_json in case a JSON value is reused. #2865 #2872
  • Fix compilation error in case symbol EOF was not found. #2755 #2756
  • Fix Compilation error when using NLOHMANN_JSON_SERIALIZE_ENUM with ordered_json on libc++. #2491 #2825

Warnings

A lot of warnings have been fixed in this release. To make sure the library remains warning-free, the CI now breaks in case a warning is found in GCC (261 warning flags), Clang (flag -Weverything with 8 exceptions), or MSVC (flag /W4).

  • Fix -Wimplicit-fallthrough warnings. #2348 #2349
  • Fix -Wfloat-equal warnings. #2909 #2911
  • Add assertions to suppress C28020 warnings. #2447
  • Fix shadow warnings. #1759 #2536 #2444
  • Fix compiler warnings in the test suite. #2537
  • Fix issues found by Visual Studio Visual Assist #2615
  • Fix unused parameter warning. #2646 #2658 #2668 #2706 #2707
  • Remove HEDLEY annotation from exception::what() to fix C28204 warning. #2673 #2680
  • Suppress C4127 warning. #2592 #2875
  • Fix truncation warning. #2572 #2874
  • Fix useless cast warning. #1777 #2114 #2893 #2902
  • Fix unknown pragma warning. #2924 #2925
  • Fix -Wswitch-enum warnings. #2927
  • Fix C4309 and C4100 warnings and treat all MSVC /W4 warnings as error. #2930
  • Suppress fewer warning flags. #2936

:zap: Improvements

Tests and CI

The CI chain has been completely overworked and now runs mostly on a dedicated Docker Image that contains all relevant tools.

  • Collected all CI calls in a CMake file which can be enabled by setting JSON_CI.
  • Linux now builds with Clang 3.5 to 12 and GCC 4.8 to 11 checking multiple C++ standards. #2540
  • Windows builds with MSVC 2015 to 2019, MinGW (GCC 8), Clang 11 and 12, and Clang-CL 11 checking multiple C++ standards.
  • Mac builds with Xcode 10.2.1 to Xcode 12.4 checking multiple C++ standards. #1798 #2561 #2737 #2790 #2817
  • Use static analysis tools Clang-Tidy, Cppcheck, Valgrind, Google Sanitizers, Clang Static Analyzer, Cpplint, and Facebook Infer.
  • Add internal checks for CMake flags, switched off exceptions, header amalgamation, self-contained headers, and exclusion of certain tests via CTest.
  • Providers: Move most Travis/AppVeyor builds to GitHub Actions. Use Drone CI for aarch64 build. Remove FOSSA. Properly select "Release" build for Travis CI builds. #2375 #2689
  • Remove #define private public hack from test files. Instead, macro JSON_PRIVATE_UNLESS_TESTED is used in the source code which defaults to private, but can be set to public to test internals. #43 #913 #1985 #2352

CMake

  • Fixed issue in CMake file that overwrote CMAKE_CXX_COMPILER when the test suite was compiled. #2344 #2384
  • Only enable CMake options JSON_BuildTests and JSON_Install by default when the library is the main project. #2513 #2514
  • Add CTest label not_reproducible to skip non-reproducible tests. #2324 #2560
  • Formatted CMake files ##2770
  • Add a CMake option JSON_SystemInclude to use SYSTEM in target_include_directories. #2762
  • Add CMake option JSON_FastTests (OFF by default) to which slow test suite.

Documentation

  • Fixed typos in the documentation. #2354 #2754
  • Extended documentation for discarded values and is_discarded() function. #2360 #2363
  • Fix Markdown of README. #2582
  • Fix example in README file. #2625 #2659
  • Fix example in parse exceptions documentation. #2679
  • Overworked documentation of number handling. #2747
  • Add link to Conan Center package to README. #2771
  • Added example for CPM.cmake. #2406
  • Update README to use HTTPS everywhere. #2789
  • Fixed consistency of using declarations in README. #2826
  • Fix documentation of tests that required a Git checkout. #2845
  • Fix code samples in GIF slideshow. #2457
  • Update documentation to reference RFC 8259 as JSON standard.
  • Add section on how to get support to README file.
  • Replaced links to Doxygen documentation with new API documentation.
  • Documented the effect of a bug in Microsoft's STL that makes what() member function of exception objects unusable in case _HAS_EXCEPTIONS=0 is set. #2824

Thirdparty

  • Updated Hedley to version 15. #2367
  • Updated Doctest to version 2.4.6. #2525 #2538 #2686 #2687

:hammer: Further Changes

  • Use C++14 constructs where available. #2533
  • Fix pkg-config.pc generation. #2690
  • Add possibility to set the C++ standard via macros JSON_HAS_CPP_11, JSON_HAS_CPP_14, JSON_HAS_CPP_17, and JSON_HAS_CPP_20. By defining any of these symbols, the internal check is overridden and the provided C++ version is unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be detected incorrectly. #2730 #2731 #2749
  • Add preprocessor symbol JSON_NO_IO. When defined, headers <cstdio>, <ios>, <iosfwd>, <istream>, and <ostream> are not included and parse functions relying on these headers are excluded. This is relevant for environment where these I/O functions are disallowed for security reasons (e.g., Intel Software Guard Extensions (SGX)). #2728 #2729 #2842 #2861
  • Benchmarks are handled via FetchContent and require CMake version 3.11. Removed Google Benchmark copy. Fix default branch name for Google Benchmarks. #2795 #2796
  • Simplify object parser for CBOR. #2879 #2598
  • Cleaned up maintainer Makefiles

Licensing

  • Clarified license of is_complete_type implementation. #2534
  • License fix for integer_sequence and index_sequence implementation. #2683

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann almost 5 years ago

nlohmann-json - JSON for Modern C++ version 3.9.1

Release date: 2020-08-06 SHA-256: 7804b38146921d03374549c9e2a5e3acda097814c43caf2b96a0278e58df26e0 (json.hpp), 6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91 (include.zip)

Summary

This release fixes two bugs in the features introduced in release 3.9.0. The lexer did not accept consecutive comments, and ordered_json lacked some functions from json. All changes are backward-compatible.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:bug: Bug Fixes

  • The lexer did not accept input with two or more consecutive comments (e.g. /* one */ /* two */ []). #2330 #2332
  • The newly introduced ordered_json container did not implement the complete interface of basic_json which broke existing code when json was replaced by ordered_json, in particular when trying to call ordered_json::parse. #2315 #2319 #2331

:hammer: Further Changes

  • Install pkg-config file to CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR #2318
  • Make installation directory of pkg-config file depend on CMAKE_INSTALL_LIBDIR. #2314
  • Fix -Wimplicit-fallthrough warning. #2333
  • Fix name of Homebrew formula in documentation. #2326 #2327
  • Fix typo in documentation. #2320

:fire: Deprecated functions

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.

- C++
Published by nlohmann almost 6 years ago

nlohmann-json - JSON for Modern C++ version 3.9.0

Release date: 2020-07-27 SHA-256: d8089d52d285ef2c5368eb39ae665b39ea464206b1ca674a88a915c0245ff4f0 (json.hpp), 5b9b819aed31626aefe2eace23498cafafc1691890556cd36d2a8002f6905009 (include.zip)

JSON for Modern C++ 3.9.0 is a feature release that adds four long-awaited features, some requested five years ago.

  • The parser functions have now an option to ignore // and /* */ style comments. Though comments are not officially part of the JSON specification (see here for a discussion), comment support was a frequently requested feature, and its implementation was much less effort than continuously explaining the lack of comment support.
  • The second-most requested feature was a way to preserve the insertion order of object keys. Though this was possible via template specialization for a while, we now added a new type nlohmann::ordered_json as drop-in replacement for nlohmann::json for this.
  • To circumvent unexpected behavior, implicit conversions can now be switched off with a CMake or preprocessor option.
  • Last, but not least, a mapping between user-defined types and JSON can now be expressed using convenience macros by just listing the names of the member variables to read/write.

All changes are backward-compatible. See below the complete list of changes. See the README or the documentation for more information.

:moneybag: Note you can support this project via GitHub sponsors or PayPal.

:sparkles: New Features

  • Add optional support for comments in JSON: passing parameter ignore_comments to the parse function will treat // and /* */ comments like whitespace. #294 #363 #376 #597 #1513 #2061 #2212
  • Add type nlohmann::ordered_json to preserve insertion order of object keys. ordered_json is a specialization of basic_json and can be used wherever json is used. #106 #424 #543 #660 #727 #952 #1106 #1717 #1817 #2179 #2206 #2258
  • Add CMake option JSON_ImplicitConversions and preprocessor symbol JSON_USE_IMPLICIT_CONVERSIONS to switch off implicit conversions. Implicit conversions, though very practical, are also a source of subtle bugs or unexpected behavior and may be switched off by default in future versions. The new options allow to remove implicit conversions now. #958 #1559
  • Add convenience macros NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE and NLOHMANN_DEFINE_TYPE_INTRUSIVE to simplify serialization/deserialization code for user-defined types. #2175 #2225 #2233 #2267 #2280 #2287 #2306 #2313
  • Add high-precision number support for UBJSON. Now, any JSON value can serialized to UBJSON, and exception json.exception.out_of_range.407 will no longer occur for integers larger than 9223372036854775807 (LLONG_MAX). #2297 #2286
  • Write binary subtype as CBOR tag. #2244
  • Add option to ignore CBOR tags as alternative to treat them as invalid input. #2308 #2273 #1968

:bug: Bug Fixes

  • Fix bug in CBOR parser where allow_exceptions was not respected. #2299 #2298
  • Fix bug in CBOR parser where incomplete binary values or strings could crash the parser. #2293 #2294

:zap: Improvements

  • Make code compile with Clang on Windows. #2259 #1119
  • Use 32-bit float encoding in MessagePack wherever this is possible without loss of precision. #2201 #2196
  • Replace std::hash<nlohmann::basic_json> with a function that does not allocate memory. #2292 #2285 #2269

:hammer: Further Changes

  • Use GitLab Discussions for support and feature requests. Removed and adjusted issue templates accordingly.
  • Allow CMake 3.13+ to override options when using FetchContent. #2222
  • Add support for pkg-config. #2253
  • Add CMake option JSON_TestDataDirectory to select directory of previously downloaded test data for situations where Internet access is forbidden during testing. #2189 #2190
  • Add option to skip tests that assume the code is checked out via Git. #2189
  • Add JSON_ASSERT macro to control behavior of assert calls. #2242
  • Add CI step for GitHub CodeQL analysis (GitHub actions).
  • Add CI step for Clang 9 and Clang 10 on Windows (GitHub actions). #2259
  • Add CI step for Clang 10 CL with MSVC 2019 on Windows (GitHub actions). #2268
  • Clean up GitHub actions CI. #2300
  • Add CI step for Xcode 12 (Travis). #2262
  • Add CI step for explicit conversions (Travis, AppVeyor).
  • Remove swap specialization to support C++20. #2176
  • Add missing check for binary() function in SAX interface. #2282
  • Add test for CMake target_include_directories. #2279
  • Add test to use library in multiple translation units. #2301
  • Add more sections to new project website. #2312
  • Fix warnings. #2304 #2305 #2303 #2274 #2224 #2211 #2203
  • Cleanup maintainer Makefiles. #2264 #2274
  • Improve documentation. #2232
  • Fix inconsistency in int-to-string function. #2193

:fire: Deprecated functions

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}).

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.

- C++
Published by nlohmann almost 6 years ago

nlohmann-json - JSON for Modern C++ version 3.8.0

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.

:moneybag: Note you can now support this project via GitHub sponsors or PayPal.

:sparkles: 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: 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

:zap: 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

:hammer: 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.

:fire: 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.

- C++
Published by nlohmann almost 6 years ago

nlohmann-json - JSON for Modern C++ version 3.7.3

Release date: 2019-11-17 SHA-256: 3b5d2b8f8282b80557091514d8ab97e27f9574336c804ee666fda673a9b59926 (json.hpp), 87b5884741427220d3a33df1363ae0e8b898099fbc59f1c451113f6732891014 (include.zip)

Summary

This release fixes a bug introduced in release 3.7.2 which could yield quadratic complexity in destructor calls. All changes are backward-compatible.

:bug: Bug Fixes

  • Removed reserve() calls from the destructor which could lead to quadratic complexity. #1837 #1838

:fire: Deprecated functions

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

- C++
Published by nlohmann over 6 years ago

nlohmann-json - JSON for Modern C++ version 3.7.2

Release date: 2019-11-10 SHA-256: 0a65fcbbe1b334d3f45c9498e5ee28c3f3b2428aea98557da4a3ff12f0f14ad6 (json.hpp), 67f69c9a93b7fa0612dc1b6273119d2c560317333581845f358aaa68bff8f087 (include.zip)

Summary

Project badjsonparsers 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.

:bug: Bug Fixes

  • Fixed a bug that lead to stack overflow for deeply nested JSON values (objects, array) by changing the implementation of the destructor from a recursive to an iterative approach. #832, #1419, #1835

:hammer: Further Changes

  • Added WhiteStone Bolt. #1830

:fire: Deprecated functions

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

- C++
Published by nlohmann over 6 years ago

nlohmann-json - JSON for Modern C++ version 3.7.1

Release date: 2019-11-06 SHA-256: b5ba7228f3c22a882d379e93d08eab4349458ee16fbf45291347994eac7dc7ce (json.hpp), 77b9f54b34e7989e6f402afb516f7ff2830df551c3a36973085e2c7a6b1045fe (include.zip)

Summary

This release fixes several small bugs in the library. All changes are backward-compatible.

:bug: Bug Fixes

  • Fixed a segmentation fault when serializing std::int64_t minimum value. #1708 #1722
  • Fixed the contains() function for JSON Pointers. #1727 #1741
  • Fixed too lax SFINAE guard for conversion from std::pair and std::tuple to json. #1805 #1806 #1825 #1826
  • Fixed some regressions detected by UBSAN. Updated CI to use Clang-Tidy 7.1.0. #1716 #1728
  • Fixed integer truncation in iteration_proxy. #1797
  • Updated Hedley to v11 to fix a E2512 error in MSVC. #1799
  • Fixed a compile error in enum deserialization of non non-default-constructible types. #1647 #1821
  • Fixed the conversion from json to std::valarray.

:zap: Improvements

  • The items() function can now be used with a custom string type. #1765
  • Made json_pointer::back const. #1764 #1769
  • Meson is part of the release archive. #1672 #1694
  • Improved documentation on the Meson and Spack package manager. #1694 #1720

:hammer: Further Changes

  • Added GitHub Workflow with ubuntu-latest/GCC 7.4.0 as CI step.
  • Added GCC 9 to Travis CI to compile with C++20 support. #1724
  • Added MSVC 2019 to the AppVeyor CI. #1780
  • Added badge to fuzzing status.
  • Fixed some cppcheck warnings. #1760
  • Fixed several typos in the documentation. #1720 #1767 #1803
  • Added documentation on the JSON_THROW_USER, JSON_TRY_USER, and JSON_CATCH_USER macros to control user-defined exception handling.
  • Used GitHub's CODEOWNERS and SECURITY feature.
  • Removed GLOB from CMake files. #1779
  • Updated to Doctest 2.3.5.

:fire: Deprecated functions

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

- C++
Published by nlohmann over 6 years ago

nlohmann-json - JSON for Modern C++ version 3.7.0

Release date: 2019-07-28 SHA-256: a503214947952b69f0062f572cb74c17582a495767446347ce2e452963fc2ca4 (json.hpp), 541c34438fd54182e9cdc68dd20c898d766713ad6d901fb2c6e28ff1f1e7c10d (include.zip)

Summary

This release introduces a few convenience functions and performs a lot of house keeping (bug fixes and small improvements). All changes are backward-compatible.

:sparkles: New Features

  • Add overload of the contains function to check if a JSON pointer is valid without throwing exceptions, just like its counterpart for object keys. #1600
  • Add a function to_string to allow for generic conversion to strings. #916 #1585
  • Add return value for the emplace_back function, returning a reference to the added element just like C++17 is introducing this for std::vector. #1609
  • Add info how to use the library with the pacman package manager on MSYS2. #1670

:bug: Bug Fixes

  • Fix an issue where typedefs with certain names yielded a compilation error. #1642 #1643
  • Fix a conversion to std::string_view in the unit tests. #1634 #1639
  • Fix MSVC Debug build. #1536 #1570 #1608
  • Fix get_to method to clear existing content before writing. #1511 #1555
  • Fix a -Wc++17-extensions warning. nodiscard attributes are now only used with Clang when -std=c++17 is used. #1535 #1551

:zap: Improvements

:hammer: Further Changes

  • Use GNUInstallDirs to set library install directories. #1673
  • Fix links in the README. #1620 #1621 #1622 #1623 #1625
  • Mention json type on the documentation start page. #1616
  • Complete documentation of value() function with respect to type_error.302 exception. #1601
  • Fix links in the documentation. #1598
  • Add regression tests for MSVC. #1543 #1570
  • Use CircleCI for continuous integration.
  • Use Doozer for continuous integration on Linux (CentOS, Raspbian, Fedora)
  • Add tests to check each CMake flag (JSON_BuildTests, JSON_Install, JSON_MultipleHeaders, JSON_Sanitizer, JSON_Valgrind, JSON_NoExceptions, JSON_Coverage).
  • Use Hedley to avoid re-inventing several compiler-agnostic feature macros like 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.
  • Build and run tests on AppVeyor in DEBUG and RELEASE mode.

:fire: Deprecated functions

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

- C++
Published by nlohmann almost 7 years ago

nlohmann-json - JSON for Modern C++ version 3.6.1

Release date: 2019-03-20 SHA-256: d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a (json.hpp), 69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf (include.zip)

Summary

This release fixes a regression and a bug introduced by the earlier 3.6.0 release. All changes are backward-compatible.

:bug: Bug Fixes

  • Fixed regression of #590 which could lead to compilation errors with GCC 7 and GCC 8. #1530
  • Fixed a compilation error when <Windows.h> was included. #1531

:hammer: Further Changes

  • Fixed a warning for missing field initializers. #1527

:fire: Deprecated functions

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

- C++
Published by nlohmann about 7 years ago

nlohmann-json - JSON for Modern C++ version 3.6.0

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!

Summary

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.

:sparkles: New Features

  • Overworked the public interface for JSON Pointers. The creation of JSON Pointers is simplified with operator/ and operator/=. JSON Pointers can be inspected with empty, back, and parent_pointer, and manipulated with push_back and pop_back. #1434
  • Added a boolean method contains to check whether an element exists in a JSON object with a given key. Returns false when called on non-object types. #1471 #1474

:bug: Bug Fixes

  • Fixed a compilation issues with libc 2.12. #1483 #1514
  • Fixed endian conversion on PPC64. #1489
  • Fixed library to compile with GCC 9. #1472 #1492
  • Fixed a compilation issue with GCC 7 on CentOS. #1496
  • Fixed an integer overflow. #1447
  • Fixed buffer flushing in serializer. #1445 #1446

:zap: Improvements

  • The performance of dumping integers has been greatly improved. #1411
  • Added CMake parameter JSON_Install to control whether the library should be installed (default: on). #1330
  • Fixed a lot of compiler and linter warnings. #1400 #1435 #1502
  • Reduced required CMake version from 3.8 to 3.1. #1409 #1428 #1441 #1498
  • Added nodiscard attribute to meta(), array(), object(), from_cbor, from_msgpack, from_ubjson, from_bson, and parse. #1433

:hammer: Further Changes

  • Added missing headers. #1500
  • Fixed typos and broken links in README. #1417 #1423 #1425 #1451 #1455 #1491
  • Fixed documentation of parse function. #1473
  • Suppressed warning that cannot be fixed inside the library. #1401 #1468
  • Imroved package manager suppert:
    • Updated Buckaroo instructions. #1495
    • Improved Meson support. #1463
    • Added Conda package manager documentation. #1430
    • Added NuGet package manager documentation. #1132
  • Continuous Integration
    • Removed unstable or deprecated Travis builders (Xcode 6.4 - 8.2) and added Xcode 10.1 builder.
    • Added Clang 7 to Travis CI.
    • Fixed AppVeyor x64 builds. #1374 #1414
  • Updated thirdparty libraries:
    • Catch 1.12.0 -> 1.12.2
    • Google Benchmark 1.3.0 -> 1.4.1
    • Doxygen 1.8.15 -> 1.8.16

:fire: Deprecated functions

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

- C++
Published by nlohmann about 7 years ago

nlohmann-json - JSON for Modern C++ version 3.5.0

Release date: 2018-12-22 SHA-256: 8a6dbf3bf01156f438d0ca7e78c2971bca50eec4ca6f0cf59adf3464c43bb9d5 (json.hpp), 3564da9c5b0cf2e032f97c69baedf10ddbc98030c337d0327a215ea72259ea21 (include.zip)

Summary

This release introduces the support for structured bindings and reading from FILE*. Besides, a few bugs have been fixed. All changes are backward-compatible.

:sparkles: New Features

  • Structured bindings are now supported for JSON objects and arrays via the items() member function, so finally this code is possible: cpp 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

:bug: Bug Fixes

  • The eofbit was not set for input streams when the end of a stream was reached while parsing. #1340 #1343
  • Fixed a bug in the SAX parser for BSON arrays.

:zap: Improvements

  • Added support for Clang 5.0.1 (PS4 version). #1341 #1342

:hammer: Further Changes

  • Added a warning for implicit conversions to the documentation: It is not recommended to use implicit conversions when reading from a JSON value. Details about this recommendation can be found here. #1363
  • Fixed typos in the documentation. #1329 #1380 #1382
  • Fixed a C4800 warning. #1364
  • Fixed a -Wshadow warning #1346
  • Wrapped std::snprintf calls to avoid error in MSVC. #1337
  • Added code to allow installation via Meson. #1345

:fire: Deprecated functions

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

- C++
Published by nlohmann over 7 years ago

nlohmann-json - JSON for Modern C++ version 3.4.0

Release date: 2018-10-30 SHA-256: 63da6d1f22b2a7bb9e4ff7d6b255cf691a161ff49532dcc45d398a53e295835f (json.hpp), bfec46fc0cee01c509cf064d2254517e7fa80d1e7647fea37cf81d97c5682bdc (include.zip)

Summary

This release introduces three new features:

  • BSON (Binary JSON) is next to CBOR, MessagePack, and UBJSON the fourth binary (de)serialization format supported by the library.
  • Adjustable error handlers for invalid Unicode allows to specify the behavior when invalid byte sequences are serialized.
  • Simplified enum/JSON mapping with a macro in case the default mapping to integers is not desired.

Furthermore, some effort has been invested in improving the parse error messages. Besides, a few bugs have been fixed. All changes are backward-compatible.

:sparkles: New Features

  • The library can read and write a subset of BSON (Binary JSON). All data types known from JSON are supported, whereas other types more tied to MongoDB such as timestamps, object ids, or binary data are currently not implemented. See the README for examples. #1244 #1320
  • The behavior when the library encounters an invalid Unicode sequence during serialization can now be controlled by defining one of three Unicode error handlers: (1) throw an exception (default behavior), (2) replace invalid sequences by the Unicode replacement character (U+FFFD), or (3) ignore/filter invalid sequences. See the documentation of the dump function for examples. #1198 #1314
  • To easily specify a user-defined enum/JSON mapping, a macro NLOHMANN_JSON_SERIALIZE_ENUM has been introduced. See the README section for more information. #1208 #1323

:bug: Bug Fixes

  • fixed truncation #1286 #1315
  • fixed an issue with std::pair #1299 #1301
  • fixed an issue with std::variant #1292 #1294
  • fixed a bug in the JSON Pointer parser

:zap: Improvements

  • The diagnosis messages for parse errors have been improved: error messages now indicated line/column positions where possible (in addition to a byte count) and also the context in which the error occurred (e.g., "while parsing a JSON string"). Example: error parse 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 #1303

:hammer: Further Changes

  • improved Meson documentation #1305
  • fixed some more linter warnings #1280
  • fixed Clang detection for third-party Google Benchmark library #1277

:fire: Deprecated functions

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

- C++
Published by nlohmann over 7 years ago

nlohmann-json - JSON for Modern C++ version 3.3.0

Release date: 2018-10-05 SHA-256: f1327bb60c58757a3dd2b0c9c45d49503d571337681d950ec621f8374bcc14d4 (json.hpp), 9588d63557333aaa485e92221ec38014a85a6134e7486fe3441e0541a5a89576 (include.zip)

Summary

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.

:sparkles: New Features

  • The library can now also built with GCC 4.8. Though this compiler does not fully support C++11, it can successfully compile and run the test suite. Note that bug 57824 in GCC 4.8 still forbids to use multiline raw strings in arguments to macros. #1257
  • Added new function 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 #1231

:bug: Bug Fixes

  • Fixed a bug in the CMake file that made target_link_libraries to not properly include nlohmann_json. #1243 #1245 #1260
  • Fixed a warning in MSVC 2017 complaining about a constexpr if. #1204 #1268 #1272
  • Fixed a bug that prevented compilation with ICPC. #755 #1222
  • Improved the SFINAE correctness to fix a bug in the conversion operator. #1237 #1238
  • Fixed a -Wctor-dtor-privacy warning. #1224
  • Fixed a warning on a lambda in unevaluated context. #1225 #1230
  • Fixed a bug introduced in version 3.2.0 where defining JSON_CATCH_USER led to duplicate macro definition of JSON_INTERNAL_CATCH. #1213 #1214
  • Fixed a bug that prevented compilation with Clang 3.4.2 in RHEL 7. #1179 #1249

:zap: Improvements

  • Added documentation on CMake integration of the library. #1270
  • Changed the CMake file to use find_package(nlohmann_json) without installing the library. #1202
  • Improved error messages in case operator[] 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 #1221
  • Added a license and version information to the Meson build file. #1252
  • Removed static assertions to indicated missing to_json or from_json functions as such assertions do not play well with SFINAE. These assertions also led to problems with GMock. #960 #1212 #1228
  • The test suite now does not wait forever if run in a wrong directory and input files are not found. #1262
  • The test suite does not show deprecation warnings for deprecated functions which frequently led to confusion. #1271

:hammer: Further Changes

:fire: Deprecated functions

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

- C++
Published by nlohmann over 7 years ago

nlohmann-json - JSON for Modern C++ version 3.2.0

Release date: 2018-08-20 SHA-256: ce6b5610a051ec6795fa11c33854abebb086f0fd67c311f5921c3c07f9531b44 (json.hpp), 35ee642558b90e2f9bc758995c4788c4b4d4dec54eef95fb8f38cb4d49c8fc7c (include.zip)

Summary

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.

:sparkles: New Features

  • added a parser with a SAX interface (#971, #1153)
  • support to parse from wide string types std::wstring, std::u16string, and std::u32string; the input will be converted to UTF-8 (#1031)
  • added support for std::string_view when using C++17 (#1028)
  • allow to roundtrip 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)

:bug: Bug Fixes

  • allow to create nullptr_t from JSON allowing to properly roundtrip null values (#1169)
  • allow compare user-defined string types (#1130)
  • better support for algorithms using iterators from items() (#1045, #1134)
  • added parameter to avoid compilation error with MSVC 2015 debug builds (#1114)
  • re-added accidentially skipped unit tests (#1176)
  • fixed MSVC issue with std::swap (#1168)

:zap: Improvements

  • key() function for iterators returns a const reference rather than a string copy (#1098)
  • binary formats CBOR, MessagePack, and UBJSON now supports float as type for floating-point numbers (#1021)

:hammer: Further Changes

  • changed issue templates
  • improved continuous integration: added builders for Xcode 9.3 and 9.4, added builders for GCC 8 and Clang 6, added builder for MinGW, added builders for MSVC targeting x86
  • required CMake version is now at least 3.8 (#1040)
  • overworked CMake file wrt. packaging (#1048)
  • added package managers: Spack (#1041) and CocoaPods (#1148)
  • fixed Meson include directory (#1142)
  • preprocessor macro JSON_SKIP_UNSUPPORTED_COMPILER_CHECK can skip the rejection of unsupported compilers - use at your own risk! (#1128)
  • preprocessor macro JSON_INTERNAL_CATCH/JSON_INTERNAL_CATCH_USER allows to control the behavior of exception handling inside the library (#1187)
  • added note on char to JSON conversion
  • added note how to send security-related issue via encrypted email
  • removed dependency to std::stringstream (#1117)
  • added SPDX-License-Identifier
  • added updated JSON Parsing Test Suite, described in Parsing JSON is a Minefield 💣
  • updated to Catch 1.12.0

:fire: Deprecated functions

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

- C++
Published by nlohmann almost 8 years ago

nlohmann-json - JSON for Modern C++ version 3.1.2

Release date: 2018-03-14 SHA-256: fbdfec4b4cf63b3b565d09f87e6c3c183bdd45c5be1864d3fcb338f6f02c1733 (json.hpp), 495362ee1b9d03d9526ba9ccf1b4a9c37691abe3a642ddbced13e5778c16660c (include.zip)

Summary

This release fixes several bugs in the library. All changes are backward-compatible.

:bug: Bug Fixes

  • Fixed a memory leak occurring in the parser callback (#1001).
  • Different specializations of basic_json (e.g., using different template arguments for strings or objects) can now be used in assignments (#972, #977, #986).
  • Fixed a logical error in an iterator range check (#992).

:zap: Improvements

  • The parser and the serialization now support user-defined string types (#1006, #1009).

:hammer: Further Changes

:fire: Deprecated functions

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

- C++
Published by nlohmann about 8 years ago

nlohmann-json - JSON for Modern C++ version 3.1.1

Release date: 2018-02-13 SHA-256: e14ce5e33d6a2daf748026bd4947f3d9686ca4cfd53d10c3da46a0a9aceb7f2e (json.hpp), fde771d4b9e4f222965c00758a2bdd627d04fb7b59e09b7f3d1965abdc848505 (include.zip)

Summary

This release fixes several bugs in the library. All changes are backward-compatible.

:bug: Bug Fixes

  • Fixed parsing of CBOR strings with indefinite length (#961). Earlier versions of this library misinterpreted the CBOR standard and rejected input with the 0x7F start byte.
  • Fixed user-defined conversion to vector type (#924, #969). A wrong SFINAE check rejected code though a user-defined conversion was provided.
  • Fixed documentation of the parser behavior for objects with duplicate keys (#963). The exact behavior is not specified by RFC 8259 and the library now also provides no guarantee which object key is stored.
  • Added check to detect memory overflow when parsing UBJSON containers (#962). The optimized UBJSON format allowed for specifying an array with billions of null elements with a few bytes and the library did not check whether this size exceeded max_size().

:hammer: Further Changes

  • Code coverage is now calculated for the individual header files, allowing to find uncovered lines more quickly than by browsing through the single header version (#953, #957).
  • A Makefile target run_benchmarks was added to quickly build and run the benchmark suite.
  • The documentation was harmonized with respect to the header inclusion (#955). Now all examples and the README use #include <nlohmann/json.hpp> to allow for selecting single_include or include or whatever installation folder as include directory.
  • Added note on how to use the library with the cget package manager (#954).

:fire: Deprecated functions

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

- C++
Published by nlohmann over 8 years ago

nlohmann-json - JSON for Modern C++ version 3.1.0

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.

:sparkles: 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.

:zap: 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.

:truck: 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).

:hammer: 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.

:fire: 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.

- C++
Published by nlohmann over 8 years ago

nlohmann-json - JSON for Modern C++ version 3.0.1

Release date: 2017-12-29 SHA-256: c9b3591f1bb94e723a0cd7be861733a3a555b234ef132be1e9027a0364118c4c

Summary

This release fixes small issues in the implementation of JSON Pointer and JSON Patch. All changes are backward-compatible.

Changes

  • :bug: The "copy" operation of JSON Patch (RFC 6902) requests that it is an error if the target path points into a non-existing array or object (see #894 for a detailed description). This release fixes the implementation to detect such invalid target paths and throw an exception.
  • :bug: An array index in a JSON Pointer (RFC 6901) must be an integer. This release fixes the implementation to throw an exception in case invalid array indices such as 10e2 are used.
  • :whitecheckmark: Added the JSON Patch tests from Byron Ruth and Mike McCabe.
  • :memo: Fixed the documentation of the at(ptr) function with JSON Pointers to list all possible exceptions (see #888).
  • :memo: Updated the container overview documentation (see #883).
  • :wrench: The CMake files now respect the BUILD_TESTING option (see #846, #885)
  • :rotating_light: Fixed some compiler warnings (see #858, #882).

Deprecated functions

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

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

- C++
Published by nlohmann over 8 years ago

nlohmann-json - JSON for Modern C++ version 3.0.0

Release date: 2017-12-17 SHA-256: 076d4a0cb890a3c3d389c68421a11c3d77c64bd788e85d50f1b77ed252f2a462

Summary

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.

:boom: Breaking changes

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.

  • The library now uses user-defined exceptions instead of re-using those defined in <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).
  • When strings with a different encoding as UTF-8 were stored in JSON values, their serialization could not be parsed by the library itself, as only UTF-8 is supported. To enforce this library limitation and improve consistency, non-UTF-8 encoded strings now yield a json::type_error exception during serialization (#838). The check for valid UTF-8 is realized with code from Björn Hoehrmann.
  • NaN and infinity values can now be stored inside the JSON value without throwing an exception. They are, however, still serialized as null (#388).
  • The library's iterator tag was changed from RandomAccessIterator to BidirectionalIterator (#593). Supporting RandomAccessIterator was incorrect as it assumed an ordering of values in a JSON objects which are unordered by definition.
  • The library does not include the standard headers <iostream>, <ctype>, and <stdexcept> any more. You may need to add these headers to code relying on them.
  • Removed constructor explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr) which was deprecated in version 2.0.0 (#480).

:fire: Deprecated functions

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

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

:sparkles: New features

With all this breaking and deprecation out of the way, let's talk about features!

  • We improved the diagnostic information for syntax errors (#301). Now, an exception 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.
  • We added a non-throwing syntax check (#458): The new 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.
  • An update function was added to merge two JSON objects (#428). In case you are wondering: the name was inspired by Python.
  • The insert function now also supports an iterator range to add elements to an object.
  • The binary exchange formats CBOR and MessagePack can now be parsed from input streams and written to output streams (#477).
  • Input streams are now only read until the end of a JSON value instead of the end of the input (#367).
  • The serialization function 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).
  • Added built-in type support for C arrays (#502), 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).

:hammer: Further changes

Furthermore, there have been a lot of changes under the hood:

  • Replaced the re2c generated scanner by a self-coded version which allows for a better modularization of the parser and better diagnostics. To test the new scanner, we added millions (8,860,608 to be exact) of unit tests to check all valid and invalid byte sequences of the Unicode standard.
  • Google's OSS-Fuzz is still constantly fuzz-testing the library and found several issues that were fixed in this release (#497, #504, #514, #516, #518, #519, #575).
  • We now also ignore UTF-8 byte order marks when parsing from an iterator range (#602).
  • Values can be now moved from initializer lists (#663).
  • Updated to Catch 1.9.7. Unfortunately, Catch2 currently has some performance issues.
  • The non-exceptional paths of the library are now annotated with __builtin_expect to optimize branch prediction as long as no error occurs.
  • MSVC now produces a stack trace in MSVC if a 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).
  • Overworked the documentation and added even more examples.
  • The build workflow now relies on CMake and CTest. Special flags can be chosen with CMake, including coverage (JSON_Coverage), compilation without exceptions (JSON_NoExceptions), LLVM sanitizers (JSON_Sanitizer), or execution with Valgrind (JSON_Valgrind).
  • Added support for package managers Meson (#576), Conan (#566), Hunter (#671, #829), and vcpkg (#753).
  • Added CI builders: Xcode 8.3, 9.0, 9.1, and 9.2; GCC 7.2; Clang 3.8, 3.9, 4.0, and 5.0; Visual Studio 2017. The library is further built with C++17 settings on the latest Clang, GCC, and MSVC version to quickly detect new issues.

Moving from 2.x.x to 3.0.0

User-defined Exceptions

There are five different exceptions inheriting from json::exception:

To support these exception, the try/catch blocks of your code need to be adjusted:

| new exception | previous exception | |:--|:--| | parseerror.101 | invalidargument | | parseerror.102 | invalidargument | | parseerror.103 | invalidargument | | parseerror.104 | invalidargument | | parseerror.105 | invalidargument | | parseerror.106 | domainerror | | parseerror.107 | domainerror | | parseerror.108 | domainerror | | parseerror.109 | invalidargument | | parseerror.110 | outofrange | | parseerror.111 | invalidargument | | parseerror.112 | invalidargument | | invaliditerator.201 | domainerror | | invaliditerator.202 | domainerror | | invaliditerator.203 | domainerror | | invaliditerator.204 | outofrange | | invaliditerator.205 | outofrange | | invaliditerator.206 | domainerror | | invaliditerator.207 | domainerror | | invaliditerator.208 | domainerror | | invaliditerator.209 | domainerror | | invaliditerator.210 | domainerror | | invaliditerator.211 | domainerror | | invaliditerator.212 | domainerror | | invaliditerator.213 | domainerror | | invaliditerator.214 | outofrange | | typeerror.301 | domainerror | | typeerror.302 | domainerror | | typeerror.303 | domainerror | | typeerror.304 | domainerror | | typeerror.305 | domainerror | | typeerror.306 | domainerror | | typeerror.307 | domainerror | | typeerror.308 | domainerror | | typeerror.309 | domainerror | | typeerror.310 | domainerror | | typeerror.311 | domainerror | | typeerror.313 | domainerror | | typeerror.314 | domainerror | | typeerror.315 | domainerror | | outofrange.401 | outofrange | | outofrange.402 | outofrange | | outofrange.403 | outofrange | | outofrange.404 | outofrange | | outofrange.405 | domainerror | | othererror.501 | domain_error |

Handling of NaN and INF

  • 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.

Removal of deprecated functions

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:

cpp json j(ss, cb);

New code:

cpp json j = json::parse(ss, cb);

If no callback function is used, also the following code works:

cpp json j; j << ss;

or

cpp json j; ss >> j;

- C++
Published by nlohmann over 8 years ago

nlohmann-json - JSON for Modern C++ Version 2.1.1

Release date: 2017-02-25 SHA-256: faa2321beb1aa7416d035e7417fcfa59692ac3d8c202728f9bcc302e2d558f57

Summary

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.

Changes

  • :bug: Locales that have a different character than . 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.
  • :bug: Numbers like 1.0 were correctly parsed as floating-point number, but serialized as integer (1). Now, floating-point numbers correctly round trip.
  • :bug: Parsing incorrect JSON numbers with leading 0 (0123) could yield a buffer overflow. This is fixed now by detecting such errors directly by the lexer.
  • :bug: Constructing a JSON value from a pointer was incorrectly interpreted as a Boolean; such code will now yield a compiler error.
  • :bug: Comparing a JSON number with 0 led to a comparison with null. This is fixed now.
  • :bug: All throw calls are now wrapped in macros.
  • :lock: Starting during the preparation of this release (since 8 February 2017), commits and released files are cryptographically signed with this GPG key. Previous releases have also been signed.
  • :sparkles: The parser for MessagePack and CBOR now supports an optional start index parameter to define a byte offset for the parser.
  • :rotating_light: Some more warnings have been fixed. With Clang, the code compiles without warnings with -Weverything (well, it needs -Wno-documentation-unknown-command and -Wno-deprecated-declarations, but you get the point).
  • :hammer: The code can be compiled easier with many Android NDKs by avoiding macros like UINT8_MAX which previously required defining a preprocessor macro for compilation.
  • :zap: The unit tests now compile two times faster.
  • :heavyplussign: Cotire is used to speed up the build.
  • :pencil2: Fixed a lot of typos in the documentation.
  • :memo: Added a section to the README file that lists all used third-party code/tools.
  • :memo: Added a note on constructing a string value vs. parsing.
  • :whitecheckmark: The test suite now contains 11202597 unit tests.
  • :memo: Improved the Doxygen documentation by shortening the template parameters of class basic_json.
  • :construction_worker: Removed Doozer.
  • :construction_worker: Added Codacity.
  • :arrow_up: Upgraded Catch to version 1.7.2.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.1.0

  • Release date: 2017-01-28
  • SHA-256: a571dee92515b685784fd527e38405cf3f5e13e96edbfe3f03d6df2e363a767b

Summary

This release introduces a means to convert from/to user-defined types. The release is backwards compatible.

conversion

Changes

  • :sparkles: The library now offers an elegant way to convert from and to arbitrary value types. All you need to do is to implement two functions: to_json and from_json. Then, a conversion is as simple as putting a = between variables. See the README for more information and examples.
  • :sparkles: Exceptions can now be switched off. This can be done by defining the preprocessor symbol JSON_NOEXCEPTION or by passing -fno-exceptions to your compiler. In case the code would usually thrown an exception, abort() is now called.
  • :sparkles: Information on the library can be queried with the new (static) function meta() which returns a JSON object with information on the version, compiler, and platform. See the documentation for an example.
  • :bug: A bug in the CBOR parser was fixed which led to a buffer overflow.
  • :sparkles: The function type_name() is now public. It allows to query the type of a JSON value as string.
  • :whitecheckmark: Added the Big List of Naughty Strings as test case.
  • :arrow_up: Updated to Catch v1.6.0.
  • :memo: Some typos in the documentation have been fixed.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.10

  • Release date: 2017-01-02
  • SHA-256: ec27d4e74e9ce0f78066389a70724afd07f10761009322dc020656704ad5296d

Summary

This release fixes several security-relevant bugs in the MessagePack and CBOR parsers. The fixes are backwards compatible.

Changes

  • :bug: Fixed a lot of bugs in the CBOR and MesssagePack parsers. These bugs occurred if invalid input was parsed and then could lead in buffer overflows. These bugs were found with Google's OSS-Fuzz, see #405, #407, #408, #409, #411, and #412 for more information.
  • :construction_worker: We now also use the Doozer continuous integration platform.
  • :construction_worker: The complete test suite is now also run with Clang's address sanitizer and undefined-behavior sanitizer.
  • :whitecheckmark: Overworked fuzz testing; CBOR and MessagePack implementations are now fuzz-tested. Furthermore, all fuzz tests now include a round trip which ensures created output can again be properly parsed and yields the same JSON value.
  • :memo: Clarified documentation of find() function to always return end() when called on non-object value types.
  • :hammer: Moved thirdparty test code to test/thirdparty directory.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.9

  • Release date: 2016-12-16
  • SHA-256: fbf3396f13e187d6c214c297bddc742d918ea9b55e10bfb3d9f458b9bfdc22e5

Summary

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.

cbor

Changes

  • :sparkles: The library can now read and write the binary formats CBOR (Concise Binary Object Representation) and MessagePack. Both formats are aimed to produce a very compact representation of JSON which can be parsed very efficiently. See the README file for more information and examples.
  • :fire: simplified the iteration implementation allowing to remove dozens of lines of code
  • :bug: fixed an integer overflow error detected by Google's OSS-Fuzz
  • :bug: suppressed documentation warnings inside the library to facilitate compilation with -Wdocumentation
  • :bug: fixed an overflow detection error in the number parser
  • :memo: updated contribution guidelines to a list of frequentely asked features that will most likely be never added to the library
  • :memo: added a table of contents to the README file to add some structure
  • :memo: mentioned the many examples and the documentation in the README file
  • :hammer: split unit tests into individual independent binaries to speed up compilation and testing
  • :whitecheckmark: the test suite now contains 11201886 tests

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.8

  • Release date: 2016-12-02
  • SHA-256: b70db0ad34f8e0e61dc3f0cbab88099336c9674c193d8a3439d93d6aca2d7120

Summary

This release combines a lot of small fixes and improvements. The fixes are backwards compatible.

Changes

  • :bug: fixed a bug that froze the parser if a passed file was not found (now, std::invalid_argument is thrown)
  • :bug: fixed a bug that lead to an error of a file at EOF was parsed again (now, std::invalid_argument is thrown)
  • :sparkles: the well known functions emplace and emplace_back have been added to JSON values and work as expected
  • :zap: improved the performance of the serialization (dump function)
  • :zap: improved the performance of the deserialization (parser)
  • :construction_worker: some continuous integration images at Travis were added and retired; see here for the current continuous integration setup
  • :construction_worker: the Coverity scan works again
  • :chartwithupwards_trend: the benchmarking code has been improved to produce more stable results
  • :memo: the README file has been extended and includes more frequently asked examples
  • :whitecheckmark: the test suite now contains 8905518 tests
  • :arrow_up: updated Catch to version 1.5.8

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.7

  • Release date: 2016-11-02
  • SHA-256: 5545c323670f8165bae90b9dc6078825e86ec310d96cc4e5b47233ea43715bbf

Summary

This release fixes a few bugs in the JSON parser found in the Parsing JSON is a Minefield 💣 article. The fixes are backwards compatible.

Changes

  • The article Parsing JSON is a Minefield 💣 discusses a lot of pitfalls of the JSON specification. When investigating the published test cases, a few bugs in the library were found and fixed:
    • Files with less than 5 bytes can now be parsed without error.
    • The library now properly rejects any file encoding other than UTF-8. Furthermore, incorrect surrogate pairs are properly detected and rejected.
    • The library now accepts all but one "yes" test (ystringutf16.json): UTF-16 is not supported.
    • The library rejects all but one "no" test (nnumberthen_00.json): Null bytes are treated as end of file instead of an error. This allows to parse input from null-terminated strings.
  • The string length passed to a user-defined string literal is now exploited to choose a more efficient constructor.
  • A few grammar mistakes in the README file have been fixed.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.6

  • Release date: 2016-10-15
  • SHA256: 459cc93d5e2f503e50c6d5876eb86bfea7daf405f5a567c5a2c9abc2383756ae

Summary

This release fixes the semantics of operator[] for JSON Pointers (see below). This fix is backwards compatible.

Changes

  • 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.
  • overworked a helper SFINAE function
  • fixed some documentation issues
  • fixed the CMake files to allow to run the test suite outside the main project directory
  • restored test coverage to 100%.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.5

  • Release date: 2016-09-14
  • SHA-256: 8b7565263a44e2b7d3b89808bc73d2d639037ff0c1f379e3d56dbd77e00b98d9

Summary

This release fixes a regression bug in the stream parser (function parse() and the <</>> operators). This fix is backwards compatible.

Changes

  • Bug fix: The end of a file stream was not detected properly which led to parse errors. This bug should have been fixed with 2.0.4, but there was still a flaw in the code.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.4

  • Release date: 2016-09-11
  • SHA-256: 632ceec4c25c4e2153f71470d3a2b992c8355f6d8b4d627d05dd16095cd3aeda

Summary

This release fixes a bug in the stream parser (function parse() and the <</>> operators). This fix is backwards compatible.

Changes

  • Bug fix: The end of a file stream was not detected properly which led to parse errors.
  • Fixed a compiler warning about an unused variable.

- C++
Published by nlohmann over 9 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.3

  • Release date: 2016-08-31
  • SHA-256: 535b73efe5546fde9e763c14aeadfc7b58183c0b3cd43c29741025aba6cf6bd3

Summary

This release combines a lot of small fixes and improvements. The release is backwards compatible.

Changes

  • The parser/deserialization functions have been generalized to process any contiguous sequence of 1-byte elements (e.g., 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.
  • As a general remark on assertions: The library uses assertions to preclude undefined behavior. A prominent example for this is the 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.
  • In the course of cleaning up the parser/deserialization functions, the constructor 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.
  • Minor improvements:
    • Improved the performance of the serialization by avoiding the re-creation of a locale object.
    • Fixed two MSVC warnings. Compiling the test suite with /Wall now only warns about non-inlined functions (C4710) and the deprecation of the constructor from input-stream (C4996).
  • Some project internals:
    • The project has qualified for the Core Infrastructure Initiative Best Practices Badge. While most requirements where already satisfied, some led to a more explicit documentation of quality-ensuring procedures. For instance, static analysis is now executed with every commit on the build server. Furthermore, the contribution guidelines document how to communicate security issues privately.
    • The test suite has been overworked and split into several files to allow for faster compilation and analysis. The execute the test suite, simply execute make check.
    • The continuous integration with Travis was extended with Clang versions 3.6.0 to 3.8.1 and now includes 18 different compiler/OS combinations.
    • An 11-day run of American fuzzy lop checked 962 million inputs on the parser and found no issue.

- C++
Published by nlohmann almost 10 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.2

  • Release date: 2016-07-31
  • SHA-256: 8e97b7965b4594b00998d6704465412360e1a0ed927badb51ded8b82291a8f3d

Summary

This release combines a lot of small fixes and improvements. The release is backwards compatible.

Changes

  • The parser has been overworked, and a lot of small issues have been fixed:
    • Improved parser performance by avoiding recursion and using move semantics for the return value.
    • Unescaped control charaters \x10-\x1f are not accepted any more.
    • Fixed a bug in the parser when reading from an input stream.
    • Improved test case coverage for UTF-8 parsing: now, all valid Unicode code points are tested both escaped and unescaped.
    • The precision of output streams is now preserved by the parser.
  • Started to check the code correctness by proving termination of important loops. Furthermore, individual assertions have been replaced by a more systematic function which checks the class invariants. Note that assertions should be switched off in production by defining the preprocessor macro NDEBUG, see the documentation of assert.
  • A lot of code cleanup: removed unused headers, fixed some compiler warnings, and fixed a build error for Windows-based Clang builds.
  • Added some compile-time checks:
    • Unsupported compilers are rejected during compilation with an #error command.
    • Static assertion prohibits code with incompatible pointer types used in get_ptr().
  • Improved the documentation, and adjusted the documentation script to choose the correct version of sed.
  • Replaced a lot of "raw loops" by STL functions like 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.
  • Implemented a value() function for JSON pointers (similar to at function).
  • The Homebrew formula (see Integration) is now tested for all Xcode builds (6.1 - 8.x) with Travis.
  • Avoided output to std::cout in the test cases.

- C++
Published by nlohmann almost 10 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.1

  • Release date: 2016-06-28
  • SHA-256: ef550fcd7df572555bf068e9ec4e9d3b9e4cdd441cecb0dcea9ea7fd313f72dd

Summary

This release fixes a performance regression in the JSON serialization (function dump()). This fix is backwards compatible.

Changes

  • The locale of the output stream (or the internal string stream if a JSON value is serialized to a string) is now adjusted once for the whole serialization instead of for each floating-point number.
  • The locale of an output stream is now correctly reset to the previous value by the JSON library.

- C++
Published by nlohmann almost 10 years ago

nlohmann-json - JSON for Modern C++ Version 2.0.0

  • Release date: 2016-06-24
  • SHA-256: ac9e1fb25c2ac9ca5fc501fcd2fe3281fe04f07018a1b48820e7b1b11491bb6c

Summary

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️⃣.

Changes

  • 🔟 A JSON value now uses 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.
  • 👉 JSON Pointer (RFC 6901) support: A JSON Pointer is a string (similar to an XPath expression) to address a value inside a structured JSON value. JSON Pointers can be used in 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().
  • 🏥 JSON Patch (RFC 6902) support. A JSON Patch is a JSON value that describes the required edit operations (add, change, remove, …) to transform a JSON value into another one. A JSON Patch can be created with function 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.
  • 🇪🇺 The code is now locale-independent: Floating-point numbers are always serialized with a period (.) as decimal separator and ignores different settings from the locale.
  • 🍺 Homebrew support: Install the library with brew tap nlohmann/json && brew install nlohmann_json.
  • Added constructor to create a JSON value by parsing a std::istream (e.g., std::stringstream or std::ifstream).
  • Added 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.)
  • When parsing numbers, the sign of 0.0 (vs. -0.0) is preserved.
  • Improved MSVC 2015, Android, and MinGW support. See README for more information.
  • Improved test coverage (added 2,225,386 tests).
  • Removed some misuses of std::move.
  • Fixed several compiler warnings.
  • Improved error messages from JSON parser.
  • Updated to re2c to version 0.16 to use a minimal DFAs for the lexer.
  • Updated test suite to use Catch version 1.5.6.
  • Made type getters (is_number, etc.) and const value access constexpr.
  • Functions push_back and operator+= now work with key/value pairs passed as initializer list, e.g. j_object += {"key", 1}.
  • Overworked CMakeLists.txt to make it easier to integrate the library into other projects.

Notes

  • Parser error messages are still very vague and contain no information on the error location.
  • The implemented diff function is rather primitive and does not create minimal diffs.
  • The name of function iteration_wrapper may change in the future and the function will be deprecated in the next release.
  • Roundtripping (i.e., parsing a JSON value from a string, serializing it, and comparing the strings) of floating-point numbers is not 100% accurate. Note that RFC 7159 defines no format to internally represent numbers and states not requirement for roundtripping. Nevertheless, benchmarks like Native JSON Benchmark treat roundtripping deviations as conformance errors.

- C++
Published by nlohmann almost 10 years ago

nlohmann-json - JSON for Modern C++ Version 1.1.0

  • Release date: 2016-01-24
  • SHA-256: c0cf0e3017798ca6bb18e757ebc570d21a3bdac877845e2b9e9573d183ed2f05

Summary

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:

Changes

  • Fixed: Floating-point numbers are now serialized and deserialized properly such that rountripping works in more cases. [#185, #186, #190, #191, #194]
  • Added: The code now contains assertions to detect undefined behavior during development. As the standard function assert is used, the assertions can be switched off by defining the preprocessor symbol NDEBUG during compilation. [#168]
  • Added: It is now possible to get a reference to the stored values via the newly added function get_ref(). [#128, #184]
  • Fixed: Access to object values via keys (operator[]) now works with all kind of string representations. [#171, #189]
  • Fixed: The code now compiles again with Microsoft Visual Studio 2015. [#144, #167, #188]
  • Fixed: All required headers are now included.
  • Fixed: Typos and other small issues. [#162, #166, #175, #177, #179, #180]

Notes

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.

- C++
Published by nlohmann over 10 years ago

nlohmann-json - JSON for Modern C++ Version 1.0.0

  • Release date: 2015-12-28
  • SHA-256: 767dc2fab1819d7b9e19b6e456d61e38d21ef7182606ecf01516e3f5230446de

Summary

This is the first official release. Compared to the prerelease version 1.0.0-rc1, only a few minor improvements have been made:

Changes

  • Changed: A UTF-8 byte order mark is silently ignored.
  • Changed: sprintf is no longer used.
  • Changed: iterator_wrapper also works for const objects; note: the name may change!
  • Changed: Error messages during deserialization have been improved.
  • Added: The parse function now also works with type std::istream&&.
  • Added: Function 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.
  • Added: Public functions are tagged with the version they were introduced. This shall allow for better versioning in the future.
  • Added: All public functions and types are documented (see http://nlohmann.github.io/json/) including executable examples.
  • Added: Allocation of all types (in particular arrays, strings, and objects) is now exception-safe.
  • Added: They descriptions of thrown exceptions have been overworked and are part of the tests suite and documentation.

- C++
Published by nlohmann over 10 years ago

nlohmann-json - JSON for Modern C++ Version 1.0.0-rc1

  • Release date: 2015-07-26
  • SHA-256: b87b2565b9786abb938c1f0ac5793fa99220509084220edc45f59aab2dec57e2

Summary

The 1.0.0 release should be the first "official" release after the initial announcement of the class in January 2015 via reddit ("0.1.0") and a heavily overworked second version ("0.2.0") in February.

Changes

  • Changed: In the generic class basic_json, all JSON value types (array, object, string, bool, integer number, and floating-point) are now templated. That is, you can choose whether you like a std::list for your arrays or an std::unordered_map for your objects. The specialization json sets some reasonable defaults.
  • Changed: The library now consists of a single header, called json.hpp. Consequently, build systems such as Automake or CMake are not any longer required.
  • Changed: The deserialization is now supported by a lexer generated with re2c from file src/json.hpp.re2c. As a result, we strictly follow the JSON specification. Note neither the tool re2c nor its input are required to use the class.
  • Added: The library now satisfies the ReversibleContainer requirement. It hence provides four different iterators (iterator, const_iterator, reverse_iterator, and const_reverse_iterator), comparison functions, swap(), size(), max_size(), and empty() member functions.
  • Added: The class uses user-defined allocators which default to std::allocator, but can be templated via parameter Allocator.
  • Added: To simplify pretty-printing, the std::setw stream manipulator has been overloaded to set the desired indentation. Pretty-printing a JSON object j is as simple as std::cout << std::setw(4) << j << '\n'.
  • Changed: The type json::value_t::number is now called json::value_t::number_integer to be more symmetric compared to json::value_t::number_float.
  • Added: The documentation is generated with Doxygen and hosted at nlohmann.github.io/json. Every public member function is thoroughly described including an example which also can be tried online.
  • Added: The class is heavily unit-tested (3341774 assertions) and has a line coverage of 100%. With every commit, the code is compiled with g++ 4.9, g++ 5.0, Clang 3.6 (thanks to Travis CI), and Microsoft Visual Studio 14 2015 (thanks to AppVeyor).

- C++
Published by nlohmann almost 11 years ago