Commit Graph

4547 Commits (e75b94b31e81a7a2d8b3b9f7f53b7ce6691a169b)

Author SHA1 Message Date
Niels Lohmann 499422b303
Merge branch 'release/3.11.0' 2022-08-01 13:12:06 +02:00
Niels Lohmann ce0e13ccea
🔖 set version to 3.11.0 2022-07-31 23:19:06 +02:00
Florian Albrechtskirchinger 9aafcbe965
Move UDLs out of the global namespace (#3605)
* Move UDLs into nlohmann::literals::json_literals namespace

* Add 'using namespace' to unit tests

* Add 'using namespace' to examples

* Add 'using namespace' to README

* Move UDL mkdocs pages out of basic_json/

* Update documentation

* Update docset index

* Add JSON_GlobalUDLs CMake option

* Add unit test

* Build examples without global UDLs

* Add CI target
2022-07-31 17:38:52 +02:00
Niels Lohmann 8fd8b52907
Prepare 3.11.0 release (#3635)
* 📄 add license header

* Update Makefile

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>

* 🔥 remove unused Doxygen leftover

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-07-31 15:28:01 +02:00
Florian Albrechtskirchinger d3e347bd2d
More documentation updates for 3.11.0 (#3553)
* mkdocs: add string_view examples

* mkdocs: reference underlying operators

* mkdocs: add operator<=> examples

* mkdocs: fix style check issues

* mkdocs: tweak BJData page

* mkdocs: add CMake option hints to macros

* mkdocs: fix JSON_DISABLE_ENUM_SERIALIZATION definition

* mkdocs: fix link to unit-udt.cpp

* mkdocs: fix "Arbitrary Type Conversions" title

* mkdocs: link to api/macros/*.md instead of features/macros.md

* mkdocs: document JSON_DisableEnumSerialization CMake option

* mkdocs: encode required C++ standard in example files

* docset: detect gsed/sed

* docset: update index

* docset: fix CSS patching

* docset: add list_missing_pages make target

* docset: add list_removed_paths make target

* docset: replace page titles with name from index

* docset: add install target for Zeal docset browser

* Use GCC_TOOL in ci_test_documentation target
2022-07-31 14:05:58 +02:00
Niels Lohmann 11ba5c1120
🚨 fix warning (#3634) 2022-07-31 07:23:30 +02:00
Niels Lohmann 9472ab4f84
Add license header to new files (#3633) 2022-07-31 07:22:22 +02:00
Florian Albrechtskirchinger 66c8bb5b90
Add a unit test including windows.h (#3631) 2022-07-31 07:22:07 +02:00
Florian Albrechtskirchinger 19e4c2bda0
Add regression tests for #3204 and #3333 (#3629) 2022-07-31 07:21:48 +02:00
KsaNL fc3e64cbf9
Fixed latest build error in msvc platform (#3630)
* Fixed latest build error in msvc platform

warnings in msvc about mix/max macro while windows.h is used in the project #762

* Update for CI

None

* Update single_include/nlohmann/json.hpp

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-07-30 23:03:09 +02:00
Florian Albrechtskirchinger a2578d1d50
Disable exceptions on ICPC (#3621) 2022-07-30 22:10:49 +02:00
Florian Albrechtskirchinger d909f80960
Add versioned, ABI-tagged inline namespace and namespace macros (#3590)
* Add versioned inline namespace

Add a versioned inline namespace to prevent ABI issues when linking code
using multiple library versions.

* Add namespace macros

* Encode ABI information in inline namespace

Add _diag suffix to inline namespace if JSON_DIAGNOSTICS is enabled, and
_ldvcmp suffix if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON is enabled.

* Move ABI-affecting macros into abi_macros.hpp

* Move std_fs namespace definition into std_fs.hpp

* Remove std_fs namespace from unit test

* Format more files in tests directory

* Add unit tests

* Update documentation

* Fix GDB pretty printer

* fixup! Add namespace macros

* Derive ABI prefix from NLOHMANN_JSON_VERSION_*
2022-07-30 21:59:13 +02:00
Florian Albrechtskirchinger fca1ddda96
Fix patch::add creating nonexistent parents (#3628)
* Fix patch::add creating nonexistent parents

The previous behavior was not in accordance with RFC6902.
Add unit test.

Fixes #3134.

* Fix incorrect JSON patch unit test

Co-authored-by: Hudson00 <yagdhscdasg@gmail.com>
2022-07-30 21:23:55 +02:00
Niels Lohmann d1d79b930d
Adjust JSON Pointer examples (#3622)
* 📝 adjust JSON Pointer examples

* 👷 add test for documentation

* 📝 note platform-dependent output on some examples
2022-07-29 14:28:37 +02:00
Andrea Pappacoda 6576c3f776
build: install .pc and .cmake files to share/ (#3619)
As nlohmann_json is a header-only library, its pkg-config and cmake
config files should be installed to `share/` (GNUInstallDirs' DATADIR),
as `share/` is the canonical directory where architecture-independent
files should be stored, while `lib/` is for architecture-dependent stuff
(see the [FHS][]).

Apart from being technically correct, installing to `share/` can help
with cross-compiling, for example in Debian-based environments. If
you're interested, I'd suggest reading this [thread][].

Related to #1697

[FHS]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrshareArchitectureindependentData
[thread]: https://github.com/marzer/tomlplusplus/pull/165#issuecomment-1193146210
2022-07-29 07:43:22 +02:00
Florian Albrechtskirchinger e3095f636f
Add operator<<(json_pointer) (#3601)
* Add operator<< for json_pointer

* Deprecate json_pointer::operator string_t()

* Update documentation

* Move operator<<(basic_json) example

* Add example

* Add mkdocs-redirects

* Move operator<< and operator>> doc pages out of basic_json/

* Rename JSON pointer operator_string to operator_string_t

* Add unit test
2022-07-28 22:12:23 +02:00
Florian Albrechtskirchinger 7777300442
Install MinGW from GitHub NuGet registry (#3618)
Attempt to workaround recent, frequent failures of the MinGW jobs by
installing an internalized Chocolatey package hosted on GitHub.
2022-07-28 21:54:12 +02:00
Florian Albrechtskirchinger a87c1885cb
Re-add value_type detection to distinguish string types (#3604)
* Re-add value_type detection to is_constructible_string_type trait

* Add value_type detection to from_json for strings
2022-07-28 21:52:23 +02:00
Florian Albrechtskirchinger a714381a5f
Use swap() by ADL (#3609)
* Use swap() by ADL

* Add type to swap() exception messages
2022-07-28 21:51:45 +02:00
Florian Albrechtskirchinger 298e4a9449
Use concurrency (#3610)
Use concurrency in GitHub workflows to cancel in-progress or pending
runs for the same ref.
2022-07-28 21:51:32 +02:00
Florian Albrechtskirchinger 5520761433
Fix Unicode test timeout (for real this time!) (#3614)
* Use TIMEOUT instead of TIMEOUT_AFTER_MATCH to set test timeout
2022-07-28 21:51:11 +02:00
Niels Lohmann 2d48a4d9c5
Add documentation for comparing json and ordered_json (#3599)
* 📝 add documentation for #3443

* Apply suggestions from code review

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-07-23 20:54:40 +02:00
Florian Albrechtskirchinger e91686cc17
Make sure iterator_input_adapter advances iterators correctly (#3548)
When parsing a string containing two JSON values using iterators, after
parsing, iterator_input_adapter should have advanced to the first
character of the second value.
Add a unit test to check that this is true.
2022-07-23 14:36:10 +02:00
Niels Lohmann dbfd33a70a
Add assertion if nullptr is passed to parse function (#3593)
Addresses #3584
2022-07-23 01:26:51 +02:00
Niels Lohmann b185c5bc9d
📝 clean up after #3581 (#3596) 2022-07-22 15:35:29 +02:00
Wolf Vollprecht 09fb4819ff
add patch_inplace function (#3581)
* add patch_inplace function to json class

* add documentation

* fix up docs
2022-07-21 16:27:59 +02:00
Niels Lohmann 4b6d3638ca
📝 minor fixes (#3592) 2022-07-20 18:59:04 +02:00
Niels Lohmann feef0eb595
Add error message if test suite cannot be found (#3585)
* 🚸 add error message if test suite cannot be found

Fixes #3584
2022-07-20 12:41:33 +02:00
Niels Lohmann 527da54dcb
Use REUSE framework (#3546)
* 📄 add licenses

* 👷 add REUSE compliance check

* 📝 add badge for REUSE

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-07-20 12:38:07 +02:00
Jake Zimmerman 2a9ae2b487
Make certain usage patterns more prominent in the README (#3557)
* Make certain usage patterns more prominent in the README

We use this library extensively where I work. After pairing with many
teammates, I've learned that one common stumbling point when using this
library is how to first get a JSON value in the first place (because
once they have a variable of type `json` in hand, the API is intuitive
and mostly does what you expect).

With that in mind, I've added two subsections to the top of the Examples
section: how to read JSON from a file, and how to hardcode a JSON
literal.

I understand that these are already documented elsewhere in the Examples
section, and so these new subsections are technically redundant. But to
defend this choice:

- Redundancy in docs is actually good, because not everyone consumes
  docs in the same way or in the same order.

- Having these things called out explicitly in isolation encourages
  people to get something working faster. In later sections, these
  examples are presented alongside many other options. Having to choose
  between alternatives gets in the way of quickly prototyping something.

If you have further suggestions for how to improve or modify these docs
I'm open to them. The changes included here would really make a huge
improvement in the productivity of newer members of my team using this
library.

* Remove old TOC entry

* Put the section back

* Another tweak
2022-07-18 17:55:44 +02:00
Niels Lohmann a15683e348
📝 add badge for https://repology.org/project/nlohmann-json/versions (#3586) 2022-07-18 17:48:42 +02:00
NN d64d40518c
Ignore output directory (#3572)
* Ignore output directory

* Update .gitignore

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
2022-07-17 13:43:55 +02:00
Florian Albrechtskirchinger 71bdaf5748
Enable overriding test properties and set Unicode test timeouts (#3580)
* CMake: Add TEST_PROPERTIES to json_test_set_test_options()

Allow overriding test properties via json_test_set_test_options().

* CMake: Set timeouts for Unicode tests
2022-07-17 13:43:32 +02:00
Romain Reignier d4daaa897f
Optimize output vector adapter write (#3569)
* Add benchmark for cbor serialization and cbor binary data serialization

* Use std::vector::insert method instead of std::copy in output_vector_adapter::write_characters

This change increases a lot the performance when writing lots of binary data.
2022-07-08 08:12:00 +02:00
Florian Albrechtskirchinger 7d361ec8ef
Add overloads for more key types to ordered_map and fix ordered_map::erase(first, last) with first == last (#3564)
* Add overloads for more key types to ordered_map

Add overloads to accept additional key types defined by type trait
detail::is_usable_as_key_type to ordered_map.
The same key types that can be used with json can now also be used with
ordered_json.

* Fix ordered_map::erase(first, last) with first == last

* Modify element access unit test to also test ordered_json
2022-07-04 19:58:19 +02:00
Alexander Karzhenkov 954b10ad3b
CI: fix "JSON_MultipleHeaders" option spelling (#3555) 2022-06-25 13:38:39 +02:00
Florian Albrechtskirchinger 39e27684ea
Use DOCTEST_* compiler macros and suppress pragmas warning (#3550)
Use DOCTEST_* macros in place of predefined compiler macros for compiler
detection and version checks.

The suppression of warning -Wrange-loop-construct in unit-items.cpp
causes GCC<11 to warn about pragmas. Suppressed by adding a version
check.
2022-06-21 16:57:47 +02:00
郑少锟 87cda1d664
Use `std::iterator_traits` to extract `iterator_category` (#3544)
* Use `std::iterator_traits` to extract `iterator_category`

In third-party STL implementations, `array_t::iterator` might be a pointer (e.g., `vector` in [EASTL](https://github.com/electronicarts/EASTL)) rather than a class, in which case directly using `array_t::iterator::iterator_category` is invalid. This commit fixes it with `std::iterator_traits`, which handles pointers correctly.

* add the changes to the single-header version
2022-06-18 19:14:03 +02:00
Qianqian Fang 13730235f2
BJData dimension length can not be string_t::npos, fix #3541 (#3543)
* BJData dimension length can not be string_t::npos, fix #3541

* handle error messages on 32bit machine

* add explanation to why size can not be string_t::npos

* add test cases to 32bit unit test

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-06-18 19:12:22 +02:00
Richard Hozák f6acdbec2c
Allow disabling default enum conversions (#3536) 2022-06-16 19:34:32 +02:00
Florian Albrechtskirchinger e80945da2c
CI: Enable 32bit unit test (3) (#3532)
* Enable JSON_MultipleHeaders by default

* CI: Add single-header build

* CI: Enable 32bit unit test

* Fix "-Wuseless-cast" warnings

* Remove coverage exclusion

* Fix 32bit test case
2022-06-14 08:54:12 +02:00
Florian Albrechtskirchinger 9c31d54389
Add to_json() for std::vector<bool>::reference (#3534) 2022-06-13 13:21:55 +02:00
Niels Lohmann af34396129
Use new CI image (#3528)
* ⬆️ use new CI image

* ⬆️ use new CI image

* 🚨 fix warning

* 🔧 remove duplicate warning flags

* 💚 fix test

* 📝 update compiler versions
2022-06-12 14:31:07 +02:00
Florian Albrechtskirchinger 48a102c2c5
Fix ndarray dimension signedness, fix ndarray length overflow (2); add 32bit unit test (#3523)
* Fix ndarray dimension signness, fix ndarray length overflow, close #3519

* detect size overflow in ubjson and bjdata

* force reformatting

* Fix MSVC compiler warning

* Add value_in_range_of trait

* Use value_in_range_of trait

* Correct 408 parse_errors to out_of_range

* Add 32bit unit test

The test can be enabled by setting JSON_32bitTest=ON.

* Exclude unreachable lines from coverage

Certain lines are unreachable in 64bit builds.

Co-authored-by: Qianqian Fang <fangqq@gmail.com>
2022-06-09 08:22:58 +02:00
Niels Lohmann b6d00d1897
Small documentation fixes (#3520) 2022-06-06 16:46:55 +02:00
ivanovmp 7c65b5cdbd
Update json.hpp (#3499)
* Update json.hpp

* Remove a space
2022-06-06 13:01:46 +02:00
Florian Albrechtskirchinger 7a6e28acfa
Add assertion to converting constructor (#3517)
The converting basic_json constructor can inadvertently change the value
type of its parameter. Assert that both basic_json values are of the
same value type after conversion.
2022-06-03 21:05:44 +02:00
Florian Albrechtskirchinger 560cede06d
CI: Remove -Wstrict-overflow (#3516) 2022-06-03 20:39:24 +02:00
Niels Lohmann 6058d9a8b3
Add more macOS builders (#3485)
* 👷 add more macOS builders

* 👷 add more macOS builders

* 💚 fix macOS build

* 📝 document new Xcode versions
2022-06-03 14:03:14 +02:00
Qianqian Fang 046927cc29
Fix nlohmann/json#3513, explain is_ndarray flag (#3514)
* Fix nlohmann/json#3513, explain is_ndarray flag

* add test for ndarray size following H
2022-06-03 08:51:33 +02:00