Commit Graph

440 Commits

Author SHA1 Message Date
Niels Lohmann
dd04a32918
🐛 fix bug in diff function #1983 2020-04-13 14:35:36 +02:00
chenguoping
f5a487d1b4 fix issue1982: contains() exceptions are incorrectly raised 2020-04-13 19:41:13 +08:00
Niels Lohmann
b7be613b6e
Merge pull request #1990 from dota17/json_pointer
catch exceptions for json_pointer : ..../+99
2020-04-13 13:29:33 +02:00
Niels Lohmann
84f19d6333
Merge pull request #2034 from ArtemSarmini/gh-1920-gcc-10-incomplete-types
Templatize basic_json constructor from json_ref
2020-04-13 13:19:28 +02:00
Niels Lohmann
b0a3883081
🎨 fix format 2020-04-13 13:11:26 +02:00
Niels Lohmann
3483d923d4
Merge pull request #2033 from nlohmann/feature/issue1913
Replace deprecated std::is_pod
2020-04-13 12:32:37 +02:00
Artöm Bakri Al-Sarmini
70be9751cd typo fix 2020-04-12 23:42:26 +03:00
Artöm Bakri Al-Sarmini
ec955f08b4 Templatize basic_json ctor from json_ref 2020-04-12 22:32:39 +03:00
Niels Lohmann
4396a68d2d
Merge pull request #1984 from dota17/document-fix
Modify the document about operator==
2020-04-11 18:55:18 +02:00
Niels Lohmann
9154e991b8
Merge branch 'develop' into feature/issue1913 2020-04-11 11:33:46 +02:00
Niels Lohmann
ea0a7c7b4f
Merge pull request #2025 from ArtemSarmini/issue-1971-basic_json-push_back
Fixes #1971 (memory leak in basic_json::push_back)
2020-04-10 13:19:14 +02:00
Niels Lohmann
d01193a4e4
🎨 run "make amalgamate" 2020-04-10 13:18:12 +02:00
chenguoping
34cf7b7a48 just restart ci 2020-04-07 10:00:21 +08:00
Niels Lohmann
6a53a95c32 ⬆️ Hedley 13 2020-04-06 11:56:33 +02:00
Artöm Bakri Al-Sarmini
e4d8dc02e8 Fixes #1971 (memory leak in basic_json::push_back) 2020-04-02 15:20:25 +03:00
chenguoping
e07686f0c7 update array_index() and add testcases 2020-03-25 15:57:20 +08:00
chenguoping
2e7d340dad docs:modify the document about operator== 2020-03-25 10:18:04 +08:00
garethsb-sony
7fe16f9400 PR for #2006 to test in AppVeyor. 2020-03-24 12:53:59 +00:00
chenguoping
dcd3a6c62b move the catch of std::invalid_argument into array_index() 2020-03-23 17:24:47 +08:00
chenguoping
59cb4c93be fix C26451 warnning in serializer.hpp for VS2019 2020-03-23 16:08:47 +08:00
chenguoping
0a8216890d fix C26451 warnnings in to_chars.hpp 2020-03-23 15:27:35 +08:00
chenguoping
bfc003cadf catch exceptions for json_point : /xx/+99 2020-03-17 20:49:28 +08:00
Francois Chabot
41b0704ce1 removed move assignments from input adapters 2020-03-02 23:50:01 -05:00
Francois Chabot
c7282d5b1e simpler endian detection for older gcc versions 2020-02-20 10:19:29 -05:00
Francois Chabot
770ae6e9da accomodate older gcc 2020-02-19 16:54:09 -05:00
Francois Chabot
de35fad88e fixed missing return arg of operator=() 2020-02-19 15:23:49 -05:00
Francois Chabot
2e2cf02cfd duck-typed object input adapters 2020-02-19 14:59:31 -05:00
Francois Chabot
a0c4fc945a fixed bad friend class declaration 2020-02-19 11:23:02 -05:00
Francois Chabot
617b3cf42e templated input adapters 2020-02-19 10:32:49 -05:00
Niels Lohmann
61b46a56fb
🏗️ replace is_pod by is_trivial 2020-02-15 10:12:27 +01:00
Antoine Cœur
8d92ca865f Some typos 2020-02-02 17:29:37 +08:00
Niels Lohmann
7acf6218b6
📝 fix typo #1903 2020-01-15 17:40:03 +01:00
Niels Lohmann
0feea6168d
📝 fix scanner documentation 2020-01-12 10:22:11 +01:00
Michael Balszun
5c045f7d0a Use correct accumulator type in binary_writer if size_t != ul
- Also fixes warning in msvc about possible loss of data in
  that size computation.
2019-11-19 11:06:45 +01:00
Niels Lohmann
c5eafe74e8
🔖 set version to 3.7.3 2019-11-17 12:09:12 +01:00
Isaac Nickaein
efa13c663d Reserve stack only for top-level items 2019-11-13 15:23:08 +03:30
Isaac Nickaein
948f98cf4a Cleanups
Make our intent more clear in destruction
2019-11-12 22:24:11 +03:30
Isaac Nickaein
0f3ec003bb Remove harmful vector::reserve during destruction (#1837) 2019-11-12 22:22:55 +03:30
Niels Lohmann
be61ad1470
🎨 fix inconsistent operator style 2019-11-11 21:37:32 +01:00
Niels Lohmann
56109eacd7
🔖 set version to 3.7.2 2019-11-10 21:23:39 +01:00
Isaac Nickaein
eec1974218 Merge remote-tracking branch 'nlohmann/develop' into iterate-on-destruction 2019-11-09 14:50:48 +03:30
Niels Lohmann
aacdc6bbe3
🔖 set version to 3.7.1 2019-11-06 18:37:26 +01:00
Niels Lohmann
62dada05ca
🐛 fix conversion to std::valarray
closes #1824
2019-11-05 19:28:00 +01:00
Niels Lohmann
7bcaba0ca9
Merge pull request #1821 from AnthonyVH/develop
Fix for #1647
2019-11-05 19:15:54 +01:00
Anthony VH
c4923e3d05 Merge remote-tracking branch 'upstream/develop' into develop 2019-11-04 20:50:43 +01:00
Camille Bégué
8b686b30eb Add restriction for tuple specialization of to_json
This commit fix the issue #1825

Signed-off-by: Camille Bégué <c.begue@samsung.com>
2019-11-04 09:57:16 +01:00
Niels Lohmann
a1828bbf57
Merge pull request #1806 from cbegue/develop
Fix issue #1805
2019-11-01 19:46:19 +01:00
Camille Bégué
794a3d411a Fix issue #1805
* Add some restriction on pair partial specialization of to_json

Signed-off-by: Camille Bégué <camille.begue.pro@gmail.com>
2019-10-31 18:04:15 +01:00
Anthony Van Herrewege
ddda67a096 Don't capture json input by value (fixed #1822). 2019-10-30 16:16:34 +01:00
Anthony Van Herrewege
27d0dfc17a Fix #1647: non-member operator== breaks enum (de)serialization. 2019-10-30 14:54:52 +01:00
Florian Pigorsch
b93d414a35 Fix some spelling errors - mostly in comments & documentation.
I did not touch the Changelog file and any third party stuff.

additonal -> additional (1)
apppend -> append (2)
constuctor -> constructor (2)
contect -> context (2)
dobulequote -> doublequote (1)
elemnts -> elements (1)
exakt -> exact (2)
exluded -> exclude (1)
explicitely -> explicitly (2)
narcissic -> narcissistic (1)
ocurred -> occurred (1)
occuring -> occurring (2)
preceeds -> preceded (1)
ot -> to (2)
wehther -> whether (2)
2019-10-19 11:59:51 +02:00
Niels Lohmann
0245ae5157
Merge pull request #1797 from t-b/fix-integer-truncation
iteration_proxy: Fix integer truncation from std::size_t to int
2019-10-17 21:02:48 +02:00
Evan Nemerson
fbcbc76d10 Update Hedley to v11. 2019-10-16 13:39:40 -07:00
Thomas Braun
35b47c2793 iteration_proxy: Fix integer truncation from std::size_t to int
Bug introduced in 0f073e26 (Allow items() to be used with custom string,
2019-09-26).
2019-10-16 20:00:05 +02:00
Niels Lohmann
d187488e0d
Merge pull request #1765 from crazyjul/fix/items-with-alt-string
Allow items() to be used with custom string
2019-10-05 22:11:14 +02:00
Julien Hamaide
4615f5a980 Provide default implementation for int_to_string, but allow for overloaded function 2019-10-01 10:34:21 +02:00
christian
7476f5ee0c Make json_pointer::back const (resolves #1764) 2019-10-01 00:57:27 +02:00
Julien Hamaide
0f073e26eb Allow items() to be used with custom string 2019-09-26 13:20:57 +02:00
Xav83
87afee1c39 Runs make amalgamate on the project. 2019-09-20 11:45:38 +02:00
Miguel Sacristan
e26a2904fc Fix and add test's for SFINAE problem 2019-09-10 21:36:23 +02:00
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
48e1fe03b5
🔖 set version to 3.7.0 2019-07-28 20:20:41 +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
7a23aa1c0d
Merge branch 'feature/emplace_back' into develop 2019-07-09 08:06:27 +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
9289a23a76
Merge pull request #1643 from kevinlul/develop
Fix json.hpp compilation issue with other typedefs with same name (Issue #1642)
2019-07-01 22:57:04 +02:00
Niels Lohmann
90798caa62
🚚 rename Hedley macros 2019-07-01 22:37:30 +02:00
Niels Lohmann
025f4cea42
🚨 fix warning 2019-07-01 22:29:21 +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
1be63431f3
make emplace_back return a reference #1609 2019-06-30 12:19:41 +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
Niels Lohmann
3b82a350ed
📝 mention 302 exception in value() documentation #1601 2019-06-22 09:44:12 +02:00
kevinlul
f4fca2d59a Fix #1642
While in our case, only the string case was affected, to be safe and allow the library to work with other unforeseen cases, all of the cases have been wrapped with parentheses.

Thank you @DyXel and @edo9300
2019-06-16 18:22:40 -04:00
Macr0Nerd
aa4c45ee4d Added to_string (with ugly macro) and tests 2019-04-26 18:10:45 -05:00
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
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
efa1b9a7bb
🔖 set version to 3.6.1 2019-03-20 20:50:05 +01:00
Niels Lohmann
b33093d610
🐛 fixed regression #1530 2019-03-20 14:40:23 +01:00
Niels Lohmann
9d6ab9014f
🏁 fixed a compilation error in MSVC #1531 2019-03-20 14:13:29 +01:00
Niels Lohmann
c790b9f8c0
🐛 fixed regression #1530 2019-03-20 12:41:08 +01:00
Niels Lohmann
7c55510f76
🚨 fixed some warnings #1527 2019-03-20 11:06:39 +01:00
Niels Lohmann
b37392b7ac
🔖 set version to 3.6.0 2019-03-20 00:19:07 +01:00
Niels Lohmann
002addabd8
🚨 fixed a warning 2019-03-19 23:10:21 +01:00
Niels Lohmann
18cc7ddd62
📝 completed documentation index page 2019-03-19 16:03:02 +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