1
0
mirror of https://github.com/nlohmann/json synced 2024-11-27 06:10:06 +00:00
Commit Graph

775 Commits

Author SHA1 Message Date
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
Stuart Gorman
f9f8c07792
fix: integer parsed as float when EINTR set in errno (#4506)
* fix: integer parsed as float when EINTR set in errno

* chore: make amalgamate

* chore: make pretty

---------

Co-authored-by: Stuart Gorman <Stuart.Gorman@kallipr.com>
2024-11-21 13:09:29 +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
64f68dc563
Suppress warnings in NLOHMANN_JSON_SERIALIZE_ENUM (#4497) 2024-11-17 14:29:27 +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
Niels Lohmann
4a602df34e
Add lgtm explanation (#4362) 2024-11-10 13:15:23 +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
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
Colby Haskell
1d597743d8
Fix char_traits deprecation warning (#4179) 2023-11-27 06:51:25 +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
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
alferov
6d4b72d3c3
Fix compile error with _HAS_STATIC_RTTI=0 (#4046) 2023-09-24 11:23:41 +02:00
Niels Lohmann
bbd2e1636d
Fix deprecation warning (#4161) 2023-09-23 20:16:37 +02:00
tomalakgeretkal
6e36c721f0
Fixed init-list construction when size_type is not int (#4140) 2023-09-23 17:21:40 +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
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
Niels Lohmann
80dfb049b3
Fix warning about moved from object (#3889) 2022-12-18 17:20:30 +01:00
Niels Lohmann
2ca8dabeb9
Remove a magic number (#3888) 2022-12-18 17:04:51 +01:00
Dirk Stolle
4b2c8ce6bc
Fix some typos for n-dimensional arrays (#3767) 2022-09-26 06:23:18 +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
Florian Albrechtskirchinger
307c053b9b
Add missing <numeric> include (#3719) 2022-08-30 20:55:47 +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
a92ccafd2c
Deprecate json_pointer/string_t comparisons (#3684)
* Deprecate json_pointer/string_t comparisons

* Update documentation
2022-08-07 22:26:59 +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
231f3108ff
Amalgamate the forward declaration header (#3679)
* Amalgamate the forward declaration header

* Update CONTRIBUTING and PULL_REQUEST_TEMPLATE

* Update documentation
2022-08-07 13:57:32 +02:00
Florian Albrechtskirchinger
dae5412268
Properly constrain non-string json_pointer overloads (#3681)
Thanks, @alex-700, for reminding me.
2022-08-07 13:55:09 +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
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
9472ab4f84
Add license header to new files (#3633) 2022-07-31 07:22:22 +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