1
0
mirror of https://github.com/nlohmann/json synced 2024-11-25 13:20:05 +00:00
Commit Graph

64 Commits

Author SHA1 Message Date
Colby Haskell
59da644db4
Add more specific error message when attempting to parse empty input (#4180) 2023-10-31 20:17:43 +01:00
Mathieu Westphal
6adae02ddd
Fix spellcheck issue (#4173) 2023-10-04 15:24:38 +02:00
Craig Scott
fac07e22c5
Accept NEW CMake policies up to CMake 3.14 (#4112)
Starting with CMake 3.27, deprecation warnings are issued
when asking for policy settings for CMake 3.4 or earlier.
The cmake_minimum_required() command accepts a version
range, which allows NEW policy settings up to the upper end
of that range to be used, but without raising the minimum
CMake version above the bottom of that range. This means
NEW policy settings will be used where available, without
requiring them. This change updates the project's
cmake_minimum_required() calls to use a version range to
extend the upper policy version to 3.14 where it wasn't already
at that version or higher. This prevents the deprecation warning
from CMake 3.27, and gives breathing space before a future
CMake release will start issuing similar deprecation warnings
again.
2023-09-25 09:31:26 +02:00
Niels Lohmann
1ce29fa22f
Fix CI (#4160) 2023-09-23 17:19:28 +02:00
Niels Lohmann
836b7beca4
Fix CI, again (#4083) 2023-09-07 20:41:12 +02:00
Ikko Eltociear Ashimine
788e5468e4
Fix typo in afl_driver.cpp (#4109) 2023-09-02 17:16:33 +02:00
Tomerkm
793878898f
Added to tests the file unit-algorithm.cpp (c++ 11) functions from algorithm library (#4044) 2023-06-11 09:59:57 +02:00
Niels Lohmann
ab06fc9951
Fix Clang-Tidy warnings (#4047) 2023-06-08 18:46:48 +02:00
Niels Lohmann
a0c1318830
Fix CI + new Doctest (#3985) 2023-05-21 17:23:18 +02:00
Raphael Grimm
bbe337c3a3
Prevent memory leak when exception is thrown in adl_serializer::to_json (#3901)
Co-authored-by: barcode <barcode@example.com>
2023-03-08 13:43:45 +01:00
Sergei Trofimovich
6cec5aefc9
custom allocators: define missing 'rebind' type (#3895) 2023-03-08 12:31:56 +01:00
Arsen Arsenović
660d0b5856
tests/unit-iterators2: use std::ranges::equals for range comparisons (#3950)
Closes https://github.com/nlohmann/json/issues/3927
2023-03-05 14:11:22 +01:00
Raphael Grimm
233d233439
Fix CI issues (#3906)
Co-authored-by: barcode <barcode@example.com>
2023-01-31 19:23:37 +01:00
Dirk Stolle
4b2c8ce6bc
Fix some typos for n-dimensional arrays (#3767) 2022-09-26 06:23:18 +02:00
Florian Albrechtskirchinger
f4658de270
Fix 'declaration hides global declaration' warning (#3751) 2022-09-19 08:04:39 +02:00
Florian Albrechtskirchinger
3d1252bbff
Replace limit macros with std::numeric_limits (#3723) 2022-09-19 08:02:50 +02:00
Niels Lohmann
58bd97e2b1
Add clang-tools to required tools for ci_static_analysis_clang (#3724)
* 💚 add clang-tools to required tools for ci_static_analysis_clang

* 🚨 update Clang-Tidy warning selection

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings

* 🚨 fix Clang-Tidy warnings (#3738)

*  revert fix

*  revert fix

* 🚨 fix Clang-Tidy warnings (#3739)

Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
2022-09-13 12:58:26 +02:00
Raphael Grimm
bed648ca55
Allow custom base class as node customization point (#3110)
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Co-authored-by: barcode <barcode@example.com>
2022-08-28 13:59:07 +02:00
Niels Lohmann
f7973f46d6
Use official Clang/GCC containers (#3703) 2022-08-27 17:28:50 +02:00
Niels Lohmann
9d69186291
🔖 set version to 3.11.2 2022-08-12 15:04:06 +02:00
Florian Albrechtskirchinger
0e61ee8b07
Restructure inline namespace and allow version component to be disabled (#3683) 2022-08-10 20:24:16 +02:00
Florian Albrechtskirchinger
31265dc69c
Make json_pointer usable as map key (again) (#3685)
* Make json_pointer usable as map key

* Add unit tests
2022-08-07 14:35:40 +02:00
Florian Albrechtskirchinger
0c7a18374c
Reimplement value() access functions (#3663)
* Reimplement value() access functions

* Merges the 'const char *' with the 'ValueType &&' overloads.
* Fixes ambiguities when default value is 0.
* Fixes 'no matching function' error when specifying ValueType template
  parameter.
* Fixes incorrect template parameter order in previous overloads.

* Add additional value() tests

* Make JSON_MultipleHeaders visible to unit tests

Define the macro JSON_TEST_USING_MULTIPLE_HEADERS to 0/1 depending on
JSON_MultipleHeaders.

* Add type_traits unit test

* Update documentation
2022-08-07 13:54:55 +02:00
Florian Albrechtskirchinger
8eee62d388
Miscellaneous small fixes (#3643)
* serve_header: suppress lgtm warning

* serve_header: fix exit code

* serve_header: replace deprecated ssl.wrap_socket()

* Add checks to unit test readme

* Add lgtm configuration file
2022-08-07 13:52:43 +02:00
Florian Albrechtskirchinger
f1e34070d2
Fix 'const' qualifier on bool& has no effect (#3678)
* Fix 'const' qualifier on bool& has no effect

Thanks, @georgthegreat, for pointing out this issue.

* Extend std::vector<bool> unit test
2022-08-07 13:50:08 +02:00
Florian Albrechtskirchinger
9e1a7c85e3
Add json_pointer/string_t equality comparison operators (#3664) 2022-08-05 14:08:27 +02:00
Florian Albrechtskirchinger
32242022f7
Minor BJData fixes (#3637)
* Replace vector/map LUTs in binary_reader with arrays

* Replace string_t::npos in binary_reader
2022-08-03 09:15:37 +02:00
Niels Lohmann
f2020da0dd
🔖 set version to 3.11.1 2022-08-01 23:27:58 +02:00
Florian Albrechtskirchinger
cbaf1033be
Fix global UDLs (#3646)
* Add ci_test_noglobaludls to CI

* Really default JSON_GLOBAL_UDLS to 1

* Test global UDLs

* Suppress warnings

* Clarify documentation
2022-08-01 22:42:35 +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
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
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
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
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
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
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
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
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
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
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