Niels Lohmann
06ccd43a2a
Merge pull request #1722 from t-b/fix-int64-min-issue
...
Fix int64 min issue
2019-09-10 07:58:02 +02:00
Thomas Braun
6ce2f35ba8
Fix outputting extreme integer values in edge cases
...
For some gcc version (Ubuntu 5.5.0-12ubuntu1~16.04) the existing code
crashes when the minimum value of int64_t is outputted.
Resurrect the code from before 546e2cbf
(🚨 fixed some warnings,
2019-03-13) but delegate the sign removal so that the compilers don't
complain about taking the negative value of an unsigned value.
In addition we also rewrite the expression so that we first increment
and then negate.
The definition of remove_sign(number_unsigned_t) is never called as
unsigned values are never negative.
2019-09-03 13:55:15 +02:00
Thomas Braun
d5c0d52f37
external_constructor<std::valarray>: Handle empty array properly
...
Clang UBSAN complains with the following message when an empty std::valarray is passed in:
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:571:14 in
2/2 Test #68 : test-regression_all ..............***Failed 4.68 sec
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:571:14: runtime error: reference binding to null pointer of type 'const do
uble'
#0 0x6fbe57 in std::valarray<double>::operator[](unsigned long) const /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/valarray:
571:7
#1 0x6fbe57 in double const* std::begin<double>(std::valarray<double> const&) /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/v
alarray:1207
#2 0x6fbe57 in void nlohmann::detail::external_constructor<(nlohmann::detail::value_t)2>::construct<nlohmann::basic_json<std::map, std::vector, s
td::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_seri
alizer>, double, 0>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool
, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&, std::valarray<double> const&) /home/firma/devel/json/include/nlohmann/deta
il/conversions/to_json.hpp:157
#3 0x5e3fe3 in void nlohmann::detail::to_json<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>
, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>, double, 0>(nlohmann::basic_json<std::map, std
::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohman
n::adl_serializer>&, std::valarray<double> const&) /home/firma/devel/json/include/nlohmann/detail/conversions/to_json.hpp:270:5
#4 0x5e3fe3 in decltype((to_json(fp, std::forward<std::valarray<double>&>(fp0))) , ((void)())) nlohmann::detail::to_json_fn::operator()<nlohmann:
:basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double
, std::allocator, nlohmann::adl_serializer>, std::valarray<double>&>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std
::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&, std::valarray<double>&) c
onst /home/firma/devel/json/include/nlohmann/detail/conversions/to_json.hpp:334
#5 0x5e3fe3 in decltype((nlohmann::(anonymous namespace)::to_json(fp, std::forward<std::valarray<double>&>(fp0))) , ((void)())) nlohmann::adl_ser
ializer<std::valarray<double>, void>::to_json<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, st
d::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>, std::valarray<double>&>(nlohmann::basic_json<std:
:map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator
, nlohmann::adl_serializer>&, std::valarray<double>&) /home/firma/devel/json/include/nlohmann/adl_serializer.hpp:45
#6 0x5e3fe3 in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool,
long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::basic_json<std::valarray<double>&, std::valarray<double>, 0>(std::valarray<d
ouble>&) /home/firma/devel/json/include/nlohmann/json.hpp:1257
#7 0x5e3fe3 in _DOCTEST_ANON_FUNC_2() /home/firma/devel/json/test/src/unit-regression.cpp:1377
#8 0x77313e in doctest::Context::run() /home/firma/devel/json/test/thirdparty/doctest/doctest.h:5938:21
#9 0x777ae0 in main /home/firma/devel/json/test/thirdparty/doctest/doctest.h:6016:71
#10 0x7fae220532e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#11 0x4a6479 in _start (/home/firma/devel/json/build/test/test-regression+0x4a6479)
The important thing to note here is that a std::valarray is *not* a STL
container, so the usual containter and iterator semantics don't apply.
Therefore we have to check if the container is non-empty before.
2019-09-03 13:22:03 +02:00
Thomas Braun
61fe5f1eee
input_buffer_adapter: Fix handling of nullptr input
...
Clang UBSAN currently complains that the char * to input_buffer_adapter
is a nullptr.
Turns out it is actually required to accept nullptr, see for example
line 415 in input_adapters.hpp
...
// the address of first cannot be used: use nullptr
ia = std::make_shared<input_buffer_adapter>(nullptr, len);
....
Therefore we have to handle it gracefully here. We now also ignore the
length parameter l if b is a nullptr.
2019-09-03 13:22:03 +02:00
Niels Lohmann
323cf95d8c
🚨 fix linter warning
2019-07-21 14:04:49 +02:00
Niels Lohmann
cf8251eb54
🚑 fix compiler errors
2019-07-14 21:19:55 +02:00
Niels Lohmann
a501365ea2
Merge branch 'feature/hedley' into develop
2019-07-14 20:58:08 +02:00
Niels Lohmann
b17440c12f
🚨 fix compiler warnings
2019-07-12 21:05:16 +02:00
Niels Lohmann
104c5c1996
Merge branch 'feature/json_pointer_contains' into develop
2019-07-09 08:08:56 +02:00
Niels Lohmann
947656544d
🚨 fix warnings
2019-07-02 21:06:42 +02:00
Niels Lohmann
346e9813c5
🚧 add more annotations
2019-07-02 20:25:51 +02:00
Niels Lohmann
90798caa62
🚚 rename Hedley macros
2019-07-01 22:37:30 +02:00
Niels Lohmann
897362191d
🔨 add NLOHMANN_JSON prefix and undef macros
2019-07-01 22:24:39 +02:00
Niels Lohmann
1720bfedd1
⚗️ add Hedley annotations
2019-06-30 22:14:02 +02:00
Niels Lohmann
258fa798f1
✨ add contains function for JSON pointers
2019-06-30 10:03:08 +02:00
Isaac Nickaein
3db14cbfae
📝 Improve doc on const_inter constructor
2019-06-24 15:40:01 +04:30
Isaac Nickaein
798e83a038
Workaround msvc2015 bug with explicit copy-constructor for const_iterator
2019-06-22 21:15:11 +04:30
Théo DELRIEU
e6e6805c6c
add built-in array support in get_to
2019-04-01 17:47:45 +02:00
Théo DELRIEU
2806b201a8
make sure values are overwritten in from_json overloads
...
Caused unexpected behaviors when using get_to with values previously
set.
Fixes !1511
2019-04-01 17:47:42 +02:00
Niels Lohmann
b52c3638f5
Merge pull request #1551 from heavywatal/fix-1535-nodiscard-clang
...
Remove C++17 extension warning from clang; #1535
2019-03-29 09:14:25 +01:00
Niels Lohmann
d21d298397
🎨 fixed indentation
2019-03-28 14:23:26 +01:00
Watal M. Iwasaki
5ccdaf643f
Remove C++17 extension warning from clang; #1535
...
- Switch off `nodiscard` for clang unless C++17 is detected.
- Detect C++ standard before the switch.
2019-03-28 14:38:58 +09:00
Niels Lohmann
9d6ab9014f
🏁 fixed a compilation error in MSVC #1531
2019-03-20 14:13:29 +01:00
Niels Lohmann
7c55510f76
🚨 fixed some warnings #1527
2019-03-20 11:06:39 +01:00
Niels Lohmann
002addabd8
🚨 fixed a warning
2019-03-19 23:10:21 +01:00
Niels Lohmann
e07e8e7912
📝 updated documentation
2019-03-19 15:40:23 +01:00
Niels Lohmann
710f26f95c
📝 added documentation
2019-03-19 10:06:35 +01:00
Niels Lohmann
b224c52376
🎨 cleanup
2019-03-19 09:17:14 +01:00
Niels Lohmann
37a72dac48
💚 forgot two semicolons
2019-03-18 17:23:34 +01:00
Niels Lohmann
8d3f4f21bc
🔨 clean up
2019-03-18 13:53:48 +01:00
Niels Lohmann
22c733e6fe
📝 added documentation
2019-03-17 22:25:18 +01:00
Niels Lohmann
56f6d1d68e
💚 fix CI and #1521
2019-03-17 15:20:22 +01:00
Niels Lohmann
b8451c236f
🚨 fixed warnings
2019-03-17 12:01:49 +01:00
Niels Lohmann
34f8b4f711
🚨 fixed more warnings
2019-03-17 00:27:44 +01:00
Niels Lohmann
b02ee16721
🚨 fixed warnings
2019-03-15 15:55:52 +01:00
Niels Lohmann
8d6c033f80
Merge branch 'develop' of https://github.com/nlohmann/json into develop
2019-03-15 14:55:15 +01:00
Niels Lohmann
27011e3718
🚨 fixed warnings
2019-03-15 14:55:13 +01:00
Ferenc Nasztanovics
0067ea8f9e
Change macros to numeric_limits #1483
2019-03-13 23:44:34 +01:00
Niels Lohmann
0c65ba960e
Merge branch 'develop' of https://github.com/nlohmann/json into develop
2019-03-13 22:14:57 +01:00
Niels Lohmann
546e2cbf5e
🚨 fixed some warnings
2019-03-13 22:14:53 +01:00
Niels Lohmann
c6fc902184
Merge pull request #1489 from andreas-schwab/develop
...
Do proper endian conversions
2019-03-13 11:57:58 +01:00
Niels Lohmann
c983b67112
Merge pull request #1469 from garethsb-sony/json_pointer-append
...
Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers
2019-03-11 22:47:08 +01:00
Niels Lohmann
3cd1dac653
🚨 fix MSVC warning #1502
2019-03-11 15:33:23 +01:00
Niels Lohmann
5047c7a217
🐛 added missing include #1500
2019-03-10 22:26:57 +01:00
Andreas Schwab
bb22b1003f
Do proper endian conversions
...
This fixes all testsuite failures on big endian hosts.
2019-02-25 12:09:13 +01:00
garethsb-sony
08de9eeaca
Add json_pointer::parent_pointer (cf. std::filesystem::path::parent_path)
2019-02-25 09:26:08 +00:00
garethsb-sony
164e0e54d9
Rename private json_pointer::is_root as public json_pointer::empty for consistency with std::filesystem::path
2019-02-25 09:26:07 +00:00
garethsb-sony
c850e9d82d
Add operator/= and operator/ to construct a JSON pointer by appending two JSON pointers, as well as convenience op/= and op= to append a single unescaped token or array index; inspired by std::filesystem::path
2019-01-31 19:15:50 +00:00
past-due
45819dce54
Disable -Wmismatched-tags warning on tuple_size / tuple_element
2019-01-30 12:59:50 -05:00
Patrick Boettcher
a06e7f5d80
JSON-pointer: add operator+() returning a new json_pointer
2019-01-24 16:46:51 +01:00
Niels Lohmann
e89c946451
Merge branch 'feature/nodiscard' into develop
2019-01-20 15:41:30 +01:00
Niels Lohmann
6de4df23e4
🐛 fixed integer overflow in dump function #1447
...
Closes #1447 .
2019-01-20 12:26:01 +01:00
Niels Lohmann
e17e0d031f
Merge pull request #1446 from scinart/develop
...
attempt to fix #1445 , flush buffer in serializer::dump_escaped in UTF8_REJECT case.
2019-01-20 12:18:02 +01:00
Niels Lohmann
e36593e960
🔨 trying code from https://godbolt.org/z/-tLO1K
2019-01-20 11:12:20 +01:00
Niels Lohmann
d359fd3a8d
🚧 trying nodiscard attribute #1433
2019-01-19 17:32:23 +01:00
Niels Lohmann
b9a39b38bf
Merge pull request #1434 from pboettch/develop
...
allow push_back() and pop_back() calls on json_pointer
2019-01-19 17:07:36 +01:00
scinart
899bd94b43
flush buffer in serializer::dump_escaped case UTF8_REJECT
...
serializer use fixed buffer. Whenever it is nearly full, it is flushed to `output_adapter_t<char> o`
But the code forgets to flush when there is a invalid utf8 code point
So there will be buffer overflow.
2019-01-18 20:35:48 -05:00
Patrick Boettcher
d0c0d16110
🚨 fixed unused variable warning
...
Since 6503e83e74
"Improve dump_integer performance by implementing a more efficient int2ascii"
an unused variable and thus a warning existed.
2019-01-15 15:21:02 +01:00
Patrick Boettcher
9225cf2f57
allow push_back() and pop_back() calls on json_pointer
...
Putting pop_back() to public and creating a trivial push_back()
method allows users of nlohmann::json_pointer to manipulate an
existing json-pointer by adding or removing keys at the end.
This is useful for traversing a JSON-instance and keeping track
of its "absolute path" at any moment.
In my case for a schema-validator error-handler.
2019-01-15 14:43:46 +01:00
Niels Lohmann
e5753b14a8
🚨 fixed another linter warning #1400
...
Closes #1400 .
2019-01-13 15:40:49 +01:00
Niels Lohmann
5c04cc1009
🔨 fixed includes
2019-01-13 15:31:22 +01:00
Niels Lohmann
8e9ad346d9
🚨 fixed another linter warning
2019-01-13 13:00:54 +01:00
Isaac Nickaein
6503e83e74
Improve dump_integer performance by implementing a more efficient int2ascii
...
This commits implements a faster int2ascii inspired by "Fastware" talk given
by Andrei Alexandrescu.
See: https://www.youtube.com/watch?v=o4-CwDo2zpg
2019-01-12 08:58:30 -08:00
Niels Lohmann
c682b9879b
🚨 fixed PVS V567 warning
...
"V567 The modification of the 'position.chars_read_current_line' variable is unsequenced relative to another operation on the same variable. This may lead to undefined behavior."
2018-12-30 23:00:15 +01:00
Niels Lohmann
6f89613acd
🚨 fixed some warnings
2018-12-23 13:56:18 +01:00
Niels Lohmann
45f5611d9b
🚨 fixed two warnings
2018-12-20 22:41:48 +01:00
Niels Lohmann
85849940ba
Merge pull request #1391 from pratikpc/develop
...
Added Support for Structured Bindings
2018-12-20 08:58:08 +01:00
Pratik Chowdhury
ebd3f45808
Added Support for Structured Bindings
...
For further details, read https://github.com/nlohmann/json/issues/1388 and https://blog.tartanllama.xyz/structured-bindings/
2018-12-19 20:17:52 +05:30
Niels Lohmann
4f270e38cc
Merge pull request #1342 from davedissian/bugfix/sfinae-iterator-traits
...
Add a SFINAE friendly iterator_traits and use that instead.
2018-12-19 08:24:18 +01:00
David Avedissian
f1080d7c39
Code review.
2018-12-18 20:44:37 +00:00
Niels Lohmann
5d390e91ff
Merge pull request #1392 from mtalliance/feature/addFileInputAdapter
...
Feature/add file input adapter
2018-12-16 22:10:03 +01:00
Jonathan Dumaresq
c1c85b025c
Forget one std::FILE
2018-12-14 07:33:28 -05:00
Jonathan Dumaresq
635a4fc344
use namespace std when possible. Change the name of private variable.
2018-12-12 16:33:25 -05:00
Jonathan Dumaresq
91ff96a737
remove the const attribute
2018-12-12 14:16:12 -05:00
Jonathan Dumaresq
b7a2642fba
remove comment
2018-12-12 14:15:49 -05:00
Jonathan Dumaresq
ef283e0cf8
add tests to cover the new input adapter
2018-12-12 10:18:37 -05:00
Jonathan Dumaresq
ae48acbb23
remove non usefull code. Add small description
2018-12-12 09:28:42 -05:00
Jonathan Dumaresq
52f6fd1d91
Add the possibility of using FILE * from cstdio library to read a file. This enable the possibility of using low eand device with this library.
2018-12-11 13:17:13 -05:00
David Avedissian
2c23f0a346
Changes requested from code review.
2018-12-08 15:46:33 +00:00
Niels Lohmann
ef90d62ddf
🚨 fixed warning #1364
2018-11-21 21:17:38 +01:00
Niels Lohmann
da81e7be22
🏁 adding parentheses around std::snprintf calls #1337
2018-11-09 21:18:02 +01:00
Niels Lohmann
f80efd3954
💄 cleanup
2018-11-09 21:10:32 +01:00
mefyl
aa10382629
Set eofbit on exhausted input stream.
...
Fix issue #1340 .
The eofbit is set manually since we don't go through the
stream interface. We could maybe use the stream interface
instead, but there are some assumptions regarding which
exception go through, so this seems to be the most prudent
approach for now.
2018-11-08 11:41:17 +01:00
David Avedissian
f665a92330
Implement SFINAE friendly iterator_traits and use that instead.
2018-11-07 18:39:25 +00:00
Niels Lohmann
2f73a4d1f3
🚨 fixed a linter warning
2018-10-31 20:30:24 +01:00
Niels Lohmann
8cee0e38d9
🚑 fixed #1319
2018-10-30 17:29:05 +01:00
Niels Lohmann
d2e4f0b0d9
✏️ fixed some typos
2018-10-28 14:20:20 +01:00
Niels Lohmann
f0c1459554
🐛 fixed a bug parsing BSON strings #1320
2018-10-28 09:16:40 +01:00
Niels Lohmann
24946f67f1
🚨 fixed some more linter warnings
2018-10-28 09:15:41 +01:00
Niels Lohmann
7d0dc10169
🚨 fixed a linter warning
2018-10-27 18:34:35 +02:00
Niels Lohmann
45a761bd60
Merge branch 'develop' of https://github.com/nlohmann/json into develop
2018-10-27 18:31:06 +02:00
Niels Lohmann
4e765596f7
🔨 small improvements
2018-10-27 18:31:03 +02:00
Niels Lohmann
1308ea055d
Merge pull request #1315 from nlohmann/feature/convert_char
...
Properly convert constants to CharType
2018-10-27 16:56:00 +02:00
Niels Lohmann
85aaf91b85
Merge branch 'develop' into feature/enum_json_mapping
2018-10-27 16:52:59 +02:00
Niels Lohmann
5a6bdf5934
Merge branch 'develop' into feature/convert_char
2018-10-27 16:48:48 +02:00
Niels Lohmann
9f48bb6937
⚡ replaced vector by array #1323
2018-10-27 09:58:23 +02:00
Niels Lohmann
6384fe28db
🚨 fixed another linter warning
2018-10-26 23:12:41 +02:00
Niels Lohmann
ad639ad5e6
✨ added NLOHMANN_JSON_SERIALIZE_ENUM marco #1208
2018-10-26 14:48:20 +02:00
Niels Lohmann
544150d5a5
🚨 fixed another linter warning
2018-10-26 11:10:49 +02:00
Niels Lohmann
c2e175763c
👌 added another conversion function #1315
2018-10-25 22:47:08 +02:00