111 Commits

Author SHA1 Message Date
Sergiu Deitsch
756ca22ec5
Provide fallback for missing char8_t support (#4736) 2025-04-23 18:36:41 +02:00
Niels Lohmann
88c92e605c
Fix compilation failure and warnings with NVHPC (#4744)
* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ enable ranges support

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔥 remove ci_nvhpc job

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ enable ranges support

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔥 remove ci_nvhpc job

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 fix warning

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-04-16 16:09:21 +02:00
Niels Lohmann
96c1b52f1c
Fix conversion to std::optional (#4742)
* ⚗️ remove JSON_USE_IMPLICIT_CONVERSIONS check for from_json(json, std::optional)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ remove JSON_USE_IMPLICIT_CONVERSIONS check for from_json(json, std::optional)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ remove JSON_USE_IMPLICIT_CONVERSIONS check for from_json(json, std::optional)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ remove JSON_USE_IMPLICIT_CONVERSIONS check for from_json(json, std::optional)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ remove JSON_USE_IMPLICIT_CONVERSIONS check for from_json(json, std::optional)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ⚗️ add C++ standard library as matrix option

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

*  remove inline

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-04-15 16:10:39 +02:00
Niels Lohmann
1705bfe914
🔖 set version to 3.12.0 (#4727)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-04-11 10:41:14 +02:00
risa2000
11aa5f944d
Make std::filesystem::path conversion to/from UTF-8 encoded string explicit (#4631)
* Make std::filesystem::path conversion to/from UTF-8 encoded JSON string explicit.

Signed-off-by: Richard Musil <risa2000x@gmail.com>

* Experimental: Changing C++ standard detection logic to accommodate potential corner cases.

Signed-off-by: Richard Musil <risa2000x@gmail.com>

* Drop C++ standard tests for compilers which do not implement required features.

Signed-off-by: Richard Musil <risa2000x@gmail.com>

* Drop C++ standard tests for MSVC versions which do not implement required features.

Signed-off-by: Richard Musil <risa2000x@gmail.com>

---------

Signed-off-by: Richard Musil <risa2000x@gmail.com>
Co-authored-by: Richard Musil <risa2000x@gmail.com>
2025-04-04 10:59:23 +02:00
Niels Lohmann
d41ca94fa8
Adjust CMake minimal version (#4709)
* 🔧 adjust CMake versions

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔧 install OpenSSL for CMake

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔧 install OpenSSL for CMake

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔧 install OpenSSL for CMake

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔧 install OpenSSL for CMake

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔧 install OpenSSL for CMake

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🔨 clean up

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 📝 update documentation

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-04-01 14:42:08 +02:00
Gianfranco Costamagna
cd92c09c18
tests: Fix ignored attributes warning during build (#4670)
Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
Co-authored-by: Pragyansh Chaturvedi <pragyansh.chaturvedi@gmail.com>
2025-03-29 09:42:53 +01:00
Niels Lohmann
b477d2b95e
Suppress clang-analyzer-webkit.NoUncountedMemberChecker (#4701)
* 🚨 suppress clang-analyzer-webkit.NoUncountedMemberChecker

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 📝 add Clang 20/21

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🚨 suppress invalid misc-const-correctness warnings

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-03-29 09:38:45 +01:00
Niels Lohmann
0b6881a95f
Add regression test for #3810 (#4608)
*  add regression test for #3810

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

*  add regression test for #3810

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

*  add regression test for #3810

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

*  add regression test for #3810

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

*  add regression test for #3810

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-02-15 12:24:06 +01:00
Harinath Nampally
bf8ccc20e9
fix compilation issue (#4613)
* fix compilation issue

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* add unit test

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci failure check

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

---------

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
2025-01-22 21:28:51 +01:00
Niels Lohmann
f06604fce0
Bump the copyright years (#4606)
* 📄 bump the copyright years

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 📄 bump the copyright years

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 📄 bump the copyright years

Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>
2025-01-19 17:04:17 +01:00
Harinath Nampally
d23291ba26
use diagnostic positions in exceptions (#4585)
* add a ci step for Json_Diagnostic_Positions

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* Update ci.cmake to address review comments

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* address review comment

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix typo in the comment

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix typos in ci.cmake

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* invoke the new ci step from ubuntu.yml

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* issue4561 - use diagnostic positions for exceptions

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci_test_documentation check

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* address review comments

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci check failures for unit-diagnostic-postions.cpp

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* improvements based on review comments

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix const correctness string

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* further refinements based on reviews

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* add one more test case for full coverage

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* ci check fix - add const

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* add unit tests for json_diagnostic_postions only

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci_test_diagnostics

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

* fix ci_test_build_documentation check

Signed-off-by: Harinath Nampally <harinath922@gmail.com>

---------

Signed-off-by: Harinath Nampally <harinath922@gmail.com>
2025-01-19 10:42:21 +01:00
kimci86
8a882f32ed
Generate template functions with NLOHMANN_DEFINE_TYPE macros (#4597)
* Support any basic_json type in NLOHMANN_DEFINE_TYPE_* macros

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Test NLOHMANN_DEFINE_TYPE_* macros also support unordered_json

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Simplify test about NLOHMANN_DEFINE_TYPE_ with many arguments

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Remove extra scope in macros tests

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Remove unused test class in macros tests

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Update documentation about NLOHMANN_DEFINE_TYPE_* macros

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Fix NLOHMANN_JSON_SERIALIZE_ENUM documentation

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Mark some variables const in macros tests, fixes clang-tidy

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Workaround clang 3.5 issue with const object initialization

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Update highlighted lines in NLOHMANN_DEFINE_TYPE_* macros examples

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Fix swapped macros in documentation

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Remove extra backslashes at the end of macros

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Require basic_json type in NLOHMANN_DEFINE_TYPE_* generated functions

Signed-off-by: kimci86 <kimci86@hotmail.fr>

* Fix typos in macros documentation

Signed-off-by: kimci86 <kimci86@hotmail.fr>

---------

Signed-off-by: kimci86 <kimci86@hotmail.fr>
2025-01-18 22:59:09 +01:00
Michael Valladolid
bdb8d2b7b3
Serialize empty tuple into '[]' instead of null (#4594)
Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>
2025-01-18 20:34:11 +01:00
Niels Lohmann
26cfec34be
Clean up and document project files (#4560) 2025-01-17 06:53:35 +01:00
Michael Valladolid
2d42229f4d
Support BSON uint64 de/serialization (#4590)
* Support BSON uint64 de/serialization

Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>

* Treat 0x11 as uint64 and not timestamp specific

Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>

---------

Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com>
2025-01-10 14:59:55 +01:00
Nebojša Cvetković
2e50d5b2f3
BJData optimized binary array type (#4513) 2025-01-07 18:09:19 +01:00
Niels Lohmann
f038ac4c9d
Enable modernize-use-integer-sign-comparison check (#4581)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-01-02 13:24:05 +01:00
Nissim Armand Ben Danan
2134cb947a
Fix NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT with an empty JSON instance (#4508)
* change NLOHMANN_JSON_FROM_WITH_DEFAULT to let NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT work with an empty JSON instance

* fix ci_static_analysis_clang (ci_clang_tidy)

* change NLOHMANN_JSON_FROM_WITH_DEFAULT to let NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT work with an empty JSON instance
2024-12-31 08:16:43 +01:00
Niels Lohmann
6057b31df7
Overwork astyle call (#4573)
* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* Use ubuntu-latest image to run Valgrind (#4575)

* 🔧 use Clang image to run valgrind

* 🔧 use Clang image to run valgrind

* 🔧 use Clang image to run valgrind

* 🔧 use Ubuntu image to run valgrind

* Use Clang image to run iwyu (#4574)

* 🔧 use Clang image to run iwyu

* 🔧 use Clang image to run iwyu

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🔧 overwork astyle call

* 🎨 format code

* 🔨 clean up
2024-12-29 17:06:03 +01:00
Harinath Nampally
69c8758d51
fix the abi tests for diagnostics positions feature (#4572) 2024-12-28 16:24:52 +01:00
Einars Netlis-Galejs
af4ad7915c
Add ONLY_SERIALIZE for NLOHMANN_DEFINE_DERIVED_TYPE_* macros (#4562) 2024-12-20 11:31:22 +01:00
Sushrut Shringarputale
58f5f25968
json start/end position implementation (#4517)
* Add implementation to retrieve start and end positions of json during parse

* Add more unit tests and add start/stop parsing for arrays

* Add raw value for all types

* Add more tests and fix compiler warning

* Amalgamate

* Fix CLang GCC warnings

* Fix error in build

* Style using astyle 3.1

* Fix whitespace changes

* revert

* more whitespace reverts

* Address PR comments

* Fix failing issues

* More whitespace reverts

* Address remaining PR comments

* Address comments

* Switch to using custom base class instead of default basic_json

* Adding a basic using for a json using the new base class. Also address PR comments and fix CI failures

* Address decltype comments

* Diagnostic positions macro (#4)

Co-authored-by: Sush Shringarputale <sushring@linux.microsoft.com>

* Fix missed include deletion

* Add docs and address other PR comments (#5)

* Add docs and address other PR comments

---------

Co-authored-by: Sush Shringarputale <sushring@linux.microsoft.com>

* Address new PR comments and fix CI tests for documentation

* Update documentation based on feedback (#6)

---------

Co-authored-by: Sush Shringarputale <sushring@linux.microsoft.com>

* Address std::size_t and other comments

* Fix new CI issues

* Fix lcov

* Improve lcov case with update to handle_diagnostic_positions call for discarded values

* Fix indentation of LCOV_EXCL_STOP comments

* fix amalgamation astyle issue

---------

Co-authored-by: Sush Shringarputale <sushring@linux.microsoft.com>
2024-12-18 22:46:14 +01:00
Niels Lohmann
094bd2651b
Set parents after insert call (#4537)
* 🐛 set parents after insert call

* 🚨 fix warning
2024-12-18 09:44:09 +01:00
Niels Lohmann
620034ecec
♻️ allow patch and diff to be used with arbitrary string types (#4536) 2024-12-13 07:24:50 +01:00
peng-wang-cn
589641b175
Add support of multi-dim C-style array member of struct. (#4262)
* Add support of multi-dim C-style array.

* Support up to 4 dimensional array.

* Suppress clang-tidy checks for C-style arrays
2024-12-10 13:18:21 +01:00
Niels Lohmann
9f60e85557
Fix return value of get_ptr for unsigned integers (#4525)
* 🐛 fix return value of get_ptr for unsigned integers

* 📝 update documentation
2024-12-06 18:38:25 +01:00
Niels Lohmann
1b9a9d1f21
Update licenses (#4521)
* 📄 update licenses

* 📄 update licenses
2024-11-29 17:38:42 +01:00
Tianyi Chen
935c6eeb5a
Optimize binary get_number implementation by reading multiple bytes at once (#4391)
* multibyte binary reader

* wide_string_input_adapter fallback to get_character

Update input_adapters.hpp

* Update json.hpp

* Add from msgpack test

* Test for broken msgpack with stream, address some warnings

* Reading binary number from wchar as an error, address warnings

* Not casting float to int, it violates strict aliasing rule
2024-11-29 09:19:58 +01:00
Niels Lohmann
3d6c664de2
Allow comparing default initialized iterators (#4512) 2024-11-26 06:35:14 +01:00
Niels Lohmann
ee32bfc1c2
Make SAX output locale-independent (#4505)
* 🐛 make SAX output locale-independent #4084

*  add test

*  add test

*  add test

*  add test

*  add test

*  add test

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084

* 🐛 make SAX output locale-independent #4084
2024-11-24 21:14:00 +01:00
Niels Lohmann
a97041a98f
Skip enum tests when JSON_DisableEnumSerialization=ON (#4504)
*  skip enum tests when JSON_DisableEnumSerialization=ON

*  skip enum tests when JSON_DisableEnumSerialization=ON
2024-11-21 17:19:16 +01:00
Niels Lohmann
378e091795
Fix weak-vtables warning (#4500)
* 🔧 remove warning suppression

* 🚨 fix weak-vtables warning #4087

* 🚨 suppress -Wweak-vtables warning

* 🚨 suppress -Wweak-vtables warning

*  fix test

*  fix test

*  fix test
2024-11-20 08:29:44 +01:00
jh96
1f218e1074
Possible fix for #4485 (#4487)
* Possible fix for #4485

Throw's an exception when i is nullptr,
also added a testcase for this scenario though most likely in the wrong test file.cpp

* quick cleanup

* Fix compile issues

* moved tests around, changed exceptions, removed a possibly unneeded include

* add back include <memory> for testing something

* Ninja doesn't like not having a \n, at end of file, adding it back

* update input_adapter file to deal with empty/null file ptr.

* ran make pretty

* added test for inputadapter

* ran make amalgamate

* Update tests/src/unit-deserialization.cpp

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

* Update tests/src/unit-deserialization.cpp

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

* Update input adapters.hpp with new includes

* fix unabigious use of _, (there was a double declare)

* did the amalagamate

* rm duplicate includes

* make amalgamate again

* reorder

* amalgamate

* moved it above

* amalgamate

---------

Co-authored-by: Jordan <jordan-hoang@users.noreply.github.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
2024-11-19 13:54:04 +01:00
Niels Lohmann
e3ac5a64bf
Add test for libstdc++ (#4495)
* 👷 add test for libstdc++

* 👷 add test for libstdc++

* 💚 add fixes from #4490

* 💚 add fixes from #4490
2024-11-17 07:35:35 +01:00
Fredrik Sandhei
060414037e
feat: Rebase feature/optional to develop (#4036)
* 🚧 conversions for std::optional

* 🏁 fix <optional> inclusion

* 💚 overwork tests

* Use JSON_HAS_CPP_17 only after it has been defined

*  update tests

* 🏁 include right <optional> header

* ♻️ do not include experimental headers

* Add missing #endif after rebase

* Fix failing test

* Only define conversion to std::optional when JSON_USE_IMPLICIT_CONVERSION is disabled.

* missing endif

* Remove Wfloat-equal suppress

* amalgamate

* Move include of optional out of macro_scope; probably does not make sense to be there

* Make clang-tidy happy

* Suppress lint instead of changing to 'contains'

---------

Co-authored-by: Niels Lohmann <mail@nlohmann.me>
Co-authored-by: Markus Palonen <markus.palonen@gmail.com>
2024-11-16 17:19:33 +01:00
Captain Crutches
fde9a86c5a
Make iterator_proxy_value a forward_iterator (#4371) (#4372)
* Make iteration_proxy_value model forward_iterator

* Amalgamate

* Suppress tidy warning
2024-11-15 09:28:40 +01:00
Niels Lohmann
1825117e63
Another desperate try to fix the CI (#4489)
* 🚨 fix warning

* 💚 update actions

* 🚨 fix warning

* 🚨 fix warning

* 🚨 fix warning

* 💚 update actions

* 💚 update actions

* 🚨 fix warning

* 🚨 fix warning

* 💚 update actions

* 🚨 fix warning

* 💚 update actions

* 💚 update actions

* 💚 update actions

* 🚨 fix warning

* 🚨 fix warning

* 🚨 fix warning

* 🚨 fix warning

* 💚 update actions

* 💚 update actions

* 🚨 fix warning

* 💚 update actions

* 💚 update actions

* 💚 update actions

* 💚 update actions

* 💚 update actions
2024-11-13 10:21:26 +01:00
Niccolò Iardella
aff5a31d35
Add NLOHMANN_DEFINE_DERIVED_TYPE_* macros (#4033)
* Add NLOHMANN_DEFINE_DERIVED_TYPE_* macros

* Fix with amalgamate

* Add documentation

* Fix with amalgamate

* Fix with amalgamate

---------

Co-authored-by: Niccolò Iardella <niccolo.iardella@doriansrl.it>
2024-11-08 21:41:19 +01:00
laterlaugh
97f0bdaf9a
chore: fix some typos in comments (#4345)
chore: fix some typos in comments

Signed-off-by: laterlaugh <manziwenzhai@sina.cn>
2024-04-12 15:20:18 +02:00
Niels Lohmann
c35d260c2f
Suppress Clang-Tidy warnings (#4276) 2024-01-28 14:04:07 +01:00
Juan Carlos Arevalo Baeza
a259ecc51e
Fix to_json for enums when the enum has an unsigned underlying type. (#4237)
* Enhance the UDT unit test to expose the issue

Add a new enum type with uint64_t as the underlying type.
Use it in the overall UDT. Not strictly needed, but it helps exercise its expected usage.
Create an object of this enum type with a large value (negative if cast to int64_t).
Perform several checks on this object as converted to `json`, which fail without the fix.

* Fix the issue in the relevant `to_json` overload.

Select the correct json type depending on the signedness of the enum's underlying type.
This fixes the new checks in the unit test.

* Add the fix to the single_include

I ran `make pretty` but that modified 20 files, performing a significant amount of indentation changes, none of them related to my change.
I ran `make amalgamate`, but that did nothing. Apparently, the make rule won't run if the single_include files have already been updated by `make pretty`.
I forced `make amalgamate` to do the work by touching the file with the fix.
I then decided to keep just the minimal needed change: the addition of the fix to the single_include file.

I just am not conversant enough in Linux to know whether I installed astyle correctly (had to clone the source from a beta branch and build, in order to get support for `--squeeze-lines`).

* Resolve CI errors and use qualified `std::uint64_t`

The fix was relying on implicit conversions in the non-taken branch.
- Ordinarily (work on a C++20 codebase) I would have used `if constexpr` here, sidestepping the issue, but that's not available on C++11 so I didn't bother.
- So instead of an `if` statement, I used a compile-time constant to select the correct overload.
- This is arguably better in this case, anyway.

I was using function-style casts for typed constants, which I consider superior for constants, but the CI checks disagree, so changed all to `static_cast`.
- For some reason, the CI checks didn't point at all of them, so I hope I caught them all myself.

Built with clang14 and all unit tests pass.

---------

Co-authored-by: Juan Carlos Arevalo Baeza (JCAB) <jcab@ntdev.microsoft.com>
2023-12-14 09:26:10 +01:00
Niels Lohmann
9cca280a4d
JSON for Modern C++ 3.11.3 (#4222) 2023-11-28 22:36:31 +01:00
Niels Lohmann
f56c6e2e30
Update documentation for the next release (#4216) 2023-11-26 15:51:19 +01:00
Vyacheslav Zhdanovskiy
360ce457f4
Add serialization-only user defined type macros (#3816) 2023-11-26 13:18:20 +01:00
Colby Haskell
5d931c59a3
Fix failing CI checks (#4215) 2023-11-25 18:04:59 +01:00
Niels Lohmann
0261bc04d3
Fix CI (again) (#4196) 2023-11-01 21:23:55 +01:00
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