Compare commits

...

566 Commits

Author SHA1 Message Date
Niels Lohmann
e7452d8778 Merge branch 'release/3.8.0' into develop 2020-06-14 17:44:18 +02:00
Niels Lohmann
5f862710fe 🔖 set version to 3.8.0 2020-06-14 17:16:45 +02:00
Niels Lohmann
1ecb7884d1 👥 update contributor list 2020-06-14 15:22:08 +02:00
Niels Lohmann
c05bd90467 Merge pull request #2182 from tanuj208/develop
Improve parse_ubjson_fuzzer
2020-06-12 09:37:44 +02:00
Tanuj Garg
c3c5c03ea3 added fuzzing with different values to default argument in to_ubjson method 2020-06-10 20:50:25 +05:30
Niels Lohmann
27f5a6e827 🙈 ignore __pycache__ directory 2020-06-09 16:59:03 +02:00
Niels Lohmann
262d9cc67d 🚨 fix a maybe-uninitialized warning 2020-06-09 16:57:06 +02:00
Niels Lohmann
14881cf901 Merge pull request #2178 from nlohmann/input_adapter_tests
Add input adapter tests
2020-06-09 08:46:32 +02:00
Niels Lohmann
ae04426c85 🏁 fix for MSVC (see https://github.com/nlohmann/json/pull/2178#issuecomment-640622532) 2020-06-08 20:07:15 +02:00
Niels Lohmann
2cf16625ac add test for character types 2020-06-07 22:49:39 +02:00
Niels Lohmann
d4bc0c39af add test for character types 2020-06-07 22:47:54 +02:00
Niels Lohmann
6d73126ea9 🚨 fix warnings 2020-06-07 22:47:25 +02:00
Niels Lohmann
28048d8207 Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into develop
 Conflicts:
	doc/examples/swap__binary_t.link
2020-06-07 21:02:08 +02:00
Niels Lohmann
eca5490b94 📝 add example link for swap function 2020-06-07 21:01:13 +02:00
Niels Lohmann
8c1d26e186 📝 add documentation and example for accept function 2020-06-07 20:59:43 +02:00
Niels Lohmann
543dcee3a7 Merge pull request #2174 from nlohmann/fix_warnings
Fix warnings
2020-06-07 20:35:05 +02:00
Niels Lohmann
907803189b 🏁 fix MSVC 2015 compilation 2020-06-07 12:51:33 +02:00
Niels Lohmann
e6a7e7a16a 🚑 hotfix for #2177 2020-06-07 12:41:36 +02:00
Niels Lohmann
bf2e714e96 🚨 fix warnings 2020-06-06 14:30:17 +02:00
Niels Lohmann
7444c7fa25 Merge pull request #2145 from FrancoisChabot/1813-user-input
Fix Issue#1813: user defined input adapters
2020-06-05 14:30:39 +02:00
Niels Lohmann
dd7e25927f 🚨 fix warning 2020-06-05 08:27:15 +02:00
Niels Lohmann
5fe6b83c26 Merge pull request #2158 from dota17/output_adapter
Fix PR#1006
2020-06-05 08:25:19 +02:00
chenguoping
ad2b4ff23b recover original blank line 2020-06-05 14:23:00 +08:00
chenguoping
0f67c5849f undo: remove comment 2020-06-05 10:09:15 +08:00
Niels Lohmann
2df5f107a9 📝 add page on parsing and exceptions 2020-06-04 14:01:57 +02:00
Niels Lohmann
32bda1a7af Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into mkdocs 2020-06-04 13:07:20 +02:00
Niels Lohmann
9212590764 👥 update contributor list 2020-06-03 13:56:01 +02:00
Niels Lohmann
9708b1e9c3 🔥 remove Code Inspector 2020-06-03 13:49:46 +02:00
Niels Lohmann
68fd772fdf 👷 add Code Inspector via GitHub Action 2020-06-03 13:44:33 +02:00
Niels Lohmann
9bc2a7fa25 👷 add Code Inspector via GitHub Action 2020-06-03 13:39:56 +02:00
Niels Lohmann
c24218afe8 Merge remote-tracking branch 'origin/develop' into develop 2020-06-03 13:38:15 +02:00
Niels Lohmann
2c4be7d65c Merge pull request #2152 from TotalCaesar659/patch-1
Update URLs to HTTPS
2020-06-03 12:31:33 +02:00
Niels Lohmann
2ad847f21b 🔨 fix doxygen link 2020-06-03 12:30:42 +02:00
Niels Lohmann
fdf5a63dfd 🔨 fix Doxygen link 2020-06-03 12:30:10 +02:00
Niels Lohmann
309acb445a Merge pull request #2153 from dota17/issue#1972
Fix issue#1972
2020-06-03 12:26:17 +02:00
chenguoping
eca4b8785c fix test case in PR#1006 2020-06-02 15:44:26 +08:00
chenguoping
fff1499963 add comment about PR#1006 2020-06-02 15:43:57 +08:00
chenguoping
8cd39578e3 add test case 2020-06-01 11:34:03 +08:00
chenguoping
4350c5ed97 fix bug in issue#1972 2020-05-30 17:15:56 +08:00
TotalCaesar659
0aa13599f0 Update URLs to HTTPS 2020-05-30 06:02:25 +03:00
Francois Chabot
0da131d717 minor readme correction 2020-05-28 17:12:26 -04:00
Francois Chabot
b715a70673 changed macro order to satisfy clang 2020-05-28 12:26:29 -04:00
Francois Chabot
7646253940 fix inconsistent fwd declaration 2020-05-28 12:20:02 -04:00
Francois Chabot
ce3143a038 use correct deprecation macro 2020-05-28 12:16:10 -04:00
Francois Chabot
d575534471 brought back the from_*(ptr, len) syntax with a deprecation warning 2020-05-28 12:13:43 -04:00
Francois Chabot
248f310215 cleaned up custom iterator example 2020-05-28 10:14:55 -04:00
Francois Chabot
897061c434 amalgamate 2020-05-28 10:11:19 -04:00
Francois Chabot
7ceb06baac Merge branch '1813-user-input' of https://github.com/FrancoisChabot/json into 1813-user-input 2020-05-28 09:30:07 -04:00
Francois Chabot
dcf6175978 use the correct convention for boolean operators 2020-05-28 09:29:38 -04:00
Niels Lohmann
23c8ab95da 👥 update contributor list 2020-05-28 14:24:08 +02:00
Niels Lohmann
53ef076715 🔧 add more warning flags from GCC 10 2020-05-28 13:46:56 +02:00
Niels Lohmann
2edb5cb999 👷 fix -DJSON_BuildTests=On parameter placement 2020-05-28 13:46:47 +02:00
Niels Lohmann
61832afe15 Merge pull request #2144 from XyFreak/gcc10_type_limits
Fix issue#1939: Cast character to unsigned for comparison
2020-05-28 12:59:57 +02:00
Niels Lohmann
5ff4d7b7ff Merge branch 'develop' of https://github.com/nlohmann/json into develop 2020-05-28 12:54:13 +02:00
Niels Lohmann
fcda998ee2 🔧 add more warning flags from GCC 10 2020-05-28 12:53:22 +02:00
Francois Chabot
d3caf93ab0 Merge branch 'develop' into 1813-user-input 2020-05-28 03:40:34 -04:00
Francois Chabot
bfcd32c099 removed clang-format 2020-05-28 03:16:24 -04:00
Francois Chabot
3a91a05db6 added custom input to readme 2020-05-28 03:13:39 -04:00
Francois Chabot
a4f1cf4d00 better parse documentation 2020-05-28 02:50:58 -04:00
Francois Chabot
76b49f9ee6 misc formatting fixes 2020-05-28 02:29:53 -04:00
Niels Lohmann
9ec0e4c25b Merge pull request #2140 from nlohmann/issue1715
Respect allow_exceptions=false for binary formats
2020-05-28 07:52:26 +02:00
Niels Lohmann
a01759af0f Merge pull request #2143 from quentin-dev/develop
Fix issue#2142: readme: fix typo in CMake FetchContent example
2020-05-28 07:50:27 +02:00
Francois Chabot
377995f495 forcefully exclude arrays from being interpreted as pointers 2020-05-27 18:21:38 -04:00
Francois Chabot
b9416a26aa correct ADL lookup of arrays on Mac and Windows 2020-05-27 13:21:23 -04:00
Francois Chabot
f1969e60a3 reamalgamate 2020-05-27 12:56:26 -04:00
Francois Chabot
5684d9a498 unified input API 2020-05-27 12:40:04 -04:00
Quentin Barbarat
e44418ea26 readme: fix typo in CMake FetchContent example 2020-05-27 13:51:13 +02:00
Niels Lohmann
bb9619ef8b 📝 request more details in question template 2020-05-27 13:22:34 +02:00
Niels Lohmann
325e8ab8ab 🔧 explicitly switch on tests in CI 2020-05-27 13:22:14 +02:00
Tobias Kux
23051df2c7 Cast character to unsigned for comparison 2020-05-27 13:15:31 +02:00
Niels Lohmann
ed5c28d00c 👥 update contributor list 2020-05-27 13:07:24 +02:00
Niels Lohmann
d70d06ae41 Merge pull request #2137 from dota17/MSC_VER
Fix issue 2112
2020-05-27 08:49:19 +02:00
Niels Lohmann
e3d9b3d755 📝 add documentation of parser callbacks 2020-05-26 14:16:13 +02:00
Niels Lohmann
ace594da6a Merge branches 'develop' and 'mkdocs' of https://github.com/nlohmann/json into mkdocs 2020-05-26 13:17:55 +02:00
Niels Lohmann
3c60a66c4c Merge pull request #2104 from dota17/issue#2086
Fix issue#2086: disallow json::value_t type parameter in value()
2020-05-26 13:15:06 +02:00
Niels Lohmann
27fe50dc92 📝 add example for contains #2133
Closes #2133.
2020-05-26 12:46:04 +02:00
Niels Lohmann
25aab7ee41 Merge pull request #2136 from aokellermann/CircleCI_GCC_BleedingEdge
Add bleeding edge GCC to CI
2020-05-26 12:39:42 +02:00
chenguoping
eb50fbf926 fix issue 2112 2020-05-26 16:43:16 +08:00
Antony Kellermann
49000cd77d Update documentation to reflect addition of Arch Linux CI testing. 2020-05-25 20:46:39 -04:00
Antony Kellermann
5a72cfa0c3 Add base and base-devel to list of arch linux programs to install. 2020-05-25 20:43:15 -04:00
Antony Kellermann
1d57ddd2d4 Add -y flag to pacman to sync repos. 2020-05-25 20:24:54 -04:00
Antony Kellermann
41a84b1202 Add workflows for CircleCI so that build_stable and build_bleeding_edge jobs can run concurrently. 2020-05-25 20:17:02 -04:00
Antony Kellermann
eff2f51071 Add build_bleeding_edge job to CircleCI, mimicking the original job except using the latest Arch Linux docker image. 2020-05-25 20:14:49 -04:00
Antony Kellermann
bf4a090075 Rename build job to build_stable to be more descriptive. 2020-05-25 20:12:54 -04:00
Niels Lohmann
413df0fd88 📝 add more content to iterator page 2020-05-25 14:03:11 +02:00
Niels Lohmann
95a3c76643 📝 make examples collapsible 2020-05-24 22:45:38 +02:00
Niels Lohmann
ddf92606ab 📝 add PlantUML 2020-05-24 21:05:35 +02:00
Niels Lohmann
3400af21cd 📝 add release page 2020-05-24 13:40:43 +02:00
Niels Lohmann
a8f0cd15df 📝 add mkdocs 2020-05-24 13:03:04 +02:00
Niels Lohmann
c92a696852 📝 update documentation 2020-05-22 18:21:37 +02:00
Niels Lohmann
88292d9499 🚨 remove redundant assertions 2020-05-22 14:19:07 +02:00
Niels Lohmann
225fa58f16 🚧 add fix from #1715 2020-05-20 22:20:40 +02:00
Niels Lohmann
a82c80e9af Merge pull request #2125 from nlohmann/binary_type
Clean up implementation of binary type
2020-05-20 18:58:29 +02:00
Niels Lohmann
ae29456b3f 🚸 overwork report templates 2020-05-20 18:57:21 +02:00
Niels Lohmann
a861bdb81f Merge pull request #2121 from gistrec/fix_compilation_error_msvc
Fixed a compilation error in MSVC
2020-05-19 13:55:37 +02:00
Niels Lohmann
4d39644bd0 💚 fix build 2020-05-19 13:45:52 +02:00
Niels Lohmann
21b1680ea1 🚚 rename binary_array() to binary() 2020-05-19 13:30:22 +02:00
Niels Lohmann
86b053e916 Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-19 13:10:35 +02:00
Niels Lohmann
952a87a4f4 🚚 move byte container outside detail namespace 2020-05-19 13:08:18 +02:00
Niels Lohmann
79347b484b improve test coverage 2020-05-19 12:40:32 +02:00
Niels Lohmann
5cfa8a586e 👷 run workflows on pull requests 2020-05-18 14:01:54 +02:00
Niels Lohmann
b7ff40029a 💥 change serialization of binary values 2020-05-18 13:53:20 +02:00
Niels Lohmann
9eb19bcc27 add more tests for binary type 2020-05-18 12:33:26 +02:00
gistrec
9e765f5aed Fixed std::numeric_limit::max() call 2020-05-18 10:25:55 +00:00
gistrec
3f0cf26f7a changes to the single header were applied 2020-05-18 10:17:45 +00:00
gistrec
454480f581 fixed a compilation error in MSVC 2020-05-18 14:57:04 +07:00
Niels Lohmann
5dec7166ea Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-18 09:13:22 +02:00
Niels Lohmann
16d78a82e0 👷 add link to GitHub workflows 2020-05-18 09:12:18 +02:00
Niels Lohmann
c237aa3a68 Merge pull request #2119 from nlohmann/release_cleanup
Overwork CI
2020-05-18 09:07:36 +02:00
Niels Lohmann
904642f261 ♻️ rename internal_binary_t with binary_t 2020-05-17 22:50:27 +02:00
Niels Lohmann
1ce8a5be87 Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-17 14:11:49 +02:00
Niels Lohmann
dead99eb0e 🔨 overwork binary subtypes 2020-05-17 13:51:59 +02:00
Niels Lohmann
ab6e76dd05 Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-17 12:27:58 +02:00
Niels Lohmann
3799b3f8dd Merge pull request #2116 from nlohmann/issue2113
Fix warnings from Clang 10 and GCC 9
2020-05-17 12:19:06 +02:00
Niels Lohmann
6154d50a9f Merge pull request #2115 from nlohmann/issue2089
Do not include <ciso646> when using C++17
2020-05-17 12:17:17 +02:00
Niels Lohmann
28e20bd9e4 🚨 fix warnings #2113 2020-05-16 14:26:17 +02:00
Niels Lohmann
ad32f576bd Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-16 13:22:23 +02:00
Niels Lohmann
c0cf67ead3 Merge branch 'develop' of https://github.com/nlohmann/json into binary_type 2020-05-16 12:58:13 +02:00
Niels Lohmann
f40a9f876a Merge pull request #2044 from dota17/issue#1719
Fix issue#1719
2020-05-16 12:57:00 +02:00
Niels Lohmann
3ed059f6ff revert faulty changes 2020-05-16 12:56:18 +02:00
Niels Lohmann
bc1886fb60 ♻️ refine interface of wrapped_binary_t 2020-05-15 23:21:49 +02:00
Niels Lohmann
a452e8a0a1 💚 fix GCC 4.9 compilation 2020-05-15 22:38:18 +02:00
chenguoping
ed9c205b5d add somes test cases 2020-05-15 21:48:29 +08:00
chenguoping
5dd27f1a9f compare against max float and min float before converting 2020-05-15 21:47:59 +08:00
Niels Lohmann
daf2d296dd ♻️ move wrapped binary type to separate file 2020-05-15 14:12:32 +02:00
chenguoping
779a0ec7df update 2020-05-15 17:35:43 +08:00
Niels Lohmann
bcf4f3ce9a 📝 add warning for items() on temporary objects #2040 2020-05-14 19:06:48 +02:00
Niels Lohmann
fc267af909 📝 update CI list 2020-05-14 17:53:00 +02:00
chenguoping
e175150f5b fix UBSAN 2020-05-14 20:54:47 +08:00
Niels Lohmann
f4cc729054 🔊 add compiler version output 2020-05-14 13:37:59 +02:00
Niels Lohmann
e91236e6d3 🔊 add compiler version output 2020-05-14 13:33:10 +02:00
chenguoping
8f5b5c7469 use json_test_data version 2.0.0 2020-05-14 15:11:38 +08:00
chenguoping
47c6570470 Add some test cases about to_cbor() 2020-05-14 15:11:38 +08:00
chenguoping
44fe284f9d Enhace to_cbor() to support +/-Infinity, NaN, and single-precision float 2020-05-14 15:10:44 +08:00
Niels Lohmann
c4c23f34c5 Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-14 07:55:09 +02:00
Niels Lohmann
33ae93beed 📝 update CI list 2020-05-14 07:55:01 +02:00
Niels Lohmann
0857140839 Merge pull request #1950 from FrancoisChabot/issues/1457
templated input adapters
2020-05-14 07:52:02 +02:00
chenguoping
cdf5327ace Fix issue#2086 2020-05-14 12:44:30 +08:00
Niels Lohmann
d7b032f565 add tests to improve coverage 2020-05-13 21:28:43 +02:00
Niels Lohmann
ec68bb3387 📝 update CI list 2020-05-13 20:18:56 +02:00
Niels Lohmann
f6f350a5c7 🔊 add operating system output 2020-05-13 14:25:51 +02:00
Niels Lohmann
a4266bbb7d Merge branch 'develop' into issues/1457 2020-05-13 12:48:46 +02:00
Niels Lohmann
855d25a76c Merge branches 'develop' and 'release_cleanup' of https://github.com/nlohmann/json into release_cleanup 2020-05-13 12:41:22 +02:00
Niels Lohmann
a414e35971 🚨 add newline to end of file 2020-05-13 12:35:11 +02:00
Niels Lohmann
def8aeb141 Merge branches 'develop' and 'release_cleanup' of https://github.com/nlohmann/json into release_cleanup 2020-05-13 07:57:03 +02:00
Niels Lohmann
9265ca7a08 Merge pull request #2099 from nlohmann/issue2082
Add tests for binary values
2020-05-13 07:56:11 +02:00
Niels Lohmann
6778ad8b0a 📝 update year 2020-05-12 22:26:55 +02:00
Niels Lohmann
7dbe5cf904 📝 update badges 2020-05-12 21:43:33 +02:00
Niels Lohmann
94115a302e 🏁 exclude slow Unicode test 2020-05-12 21:22:47 +02:00
Niels Lohmann
8c44c7b6de 🏁 set Windows CI to Release mode 2020-05-12 21:18:08 +02:00
Niels Lohmann
44a2158b18 👷 make debug build 2020-05-12 20:51:45 +02:00
Niels Lohmann
77e0ba8750 👷 parallelize builds 2020-05-12 20:45:18 +02:00
Niels Lohmann
6e59c8301a 👷 simplify CMake invocations 2020-05-12 20:37:50 +02:00
Niels Lohmann
ab02b08296 👷 rename workflows 2020-05-12 20:30:11 +02:00
Niels Lohmann
cd76f59af6 👷 add more GitHub actions workflows 2020-05-12 20:26:17 +02:00
Niels Lohmann
b1c1eb145e 🔧 fix maintainer target 2020-05-12 19:36:33 +02:00
Niels Lohmann
abeb80411b 📝 fix example 2020-05-12 16:28:26 +02:00
Niels Lohmann
52f5f3d29f 📝 fix example 2020-05-12 16:27:55 +02:00
Niels Lohmann
e9a845f08a 📝 fix example output 2020-05-12 16:13:33 +02:00
Niels Lohmann
8e0ae9b46f ⬆️ update Doxyfile 2020-05-12 14:37:35 +02:00
Niels Lohmann
afc30a14a7 🔧 set Wandbox script to use HTTPS 2020-05-12 14:37:22 +02:00
Niels Lohmann
6014419818 Merge branches 'develop' and 'issue2082' of https://github.com/nlohmann/json into issue2082 2020-05-12 12:28:34 +02:00
Niels Lohmann
1de30bc611 Merge pull request #2100 from nlohmann/fix_coveralls
Fix Coveralls integration
2020-05-12 12:26:22 +02:00
Niels Lohmann
76c01501f7 🔧 fix pedantic maintainer targets 2020-05-11 20:03:13 +02:00
Niels Lohmann
66dfa22de2 ⚗️ try to fix SSL issue 2020-05-11 14:24:38 +02:00
Niels Lohmann
0ad595709d ⚗️ try to fix SSL issue 2020-05-11 13:40:43 +02:00
Niels Lohmann
cbb2d4e4d8 ⚗️ try to fix SSL issue 2020-05-11 13:29:40 +02:00
Niels Lohmann
8389c1961b ⚗️ try to fix SSL issue 2020-05-11 13:19:22 +02:00
Niels Lohmann
19b21e61e5 ⚗️ try to fix SSL issue 2020-05-11 13:05:53 +02:00
Niels Lohmann
697305819f ⚗️ try to fix SSL issue 2020-05-11 12:37:24 +02:00
Niels Lohmann
18cbcc4135 ⚗️ try to fix SSL issue 2020-05-11 12:25:41 +02:00
Niels Lohmann
a3a803a389 📝 add FOSSA status badge 2020-05-10 13:49:26 +02:00
Niels Lohmann
5c42847011 add tests for binary type 2020-05-10 13:23:18 +02:00
Niels Lohmann
fff46ea98c add tests for binary type 2020-05-09 23:18:12 +02:00
Niels Lohmann
34430994bf add tests for binary type 2020-05-09 14:16:57 +02:00
Niels Lohmann
b036ace235 🐛 fix bug in binary constructor 2020-05-09 14:16:49 +02:00
Niels Lohmann
3fa94f0755 add tests for binary type 2020-05-09 13:46:24 +02:00
Niels Lohmann
f0c6ab4d3b 🐛 fix bug in SAX callback parser 2020-05-08 14:21:11 +02:00
Niels Lohmann
5bfb27c865 🚨 fix some warnings 2020-05-08 12:32:28 +02:00
Niels Lohmann
8c2b26de4a ⚗️ do not include <ciso646> with C++20 #2089 2020-05-07 10:17:32 +02:00
Niels Lohmann
9adb1c0235 🏁 do not include <ciso646> unless old MSVC is used #2089 2020-05-07 09:43:41 +02:00
Niels Lohmann
cf4a6552f3 add tests for binary serialization 2020-05-06 22:24:48 +02:00
Niels Lohmann
3cd2a977ae add test for get_ptr<binary_t*> 2020-05-06 22:13:55 +02:00
Niels Lohmann
1d6f7b0d4e add tests for binary serialization 2020-05-06 22:13:31 +02:00
Niels Lohmann
c10bc7efdd 🔥 remove pretty-print code for binary values 2020-05-06 22:13:08 +02:00
Niels Lohmann
ddff459fa3 add test for BSON binary subtype 2020-05-06 21:24:00 +02:00
Niels Lohmann
421a084396 add convenience function to create binary value with given subtype 2020-05-06 21:23:45 +02:00
Niels Lohmann
2b39efd545 add tests for binary type 2020-05-05 12:59:57 +02:00
Niels Lohmann
6dee8866a8 🐛 fix binary comparison 2020-05-05 12:40:04 +02:00
Niels Lohmann
908941b87d fix test cases 2020-05-05 07:47:20 +02:00
Niels Lohmann
2a34f4cd63 add tests for binary type 2020-05-04 22:07:50 +02:00
Niels Lohmann
48aa441661 add swap function for binary type 2020-05-04 22:07:36 +02:00
Niels Lohmann
a50a14088c Merge pull request #2081 from nlohmann/external_test_data
Use external test data
2020-05-04 20:58:02 +02:00
Niels Lohmann
2304629a3f 📌 use JSON test data v1.0.0 2020-05-04 16:00:00 +02:00
Niels Lohmann
e7a88b2d7f 💚 fix AppVeyor and Travis builds 2020-05-03 19:33:01 +02:00
Niels Lohmann
634fa87e5a Merge pull request #2080 from nlohmann/remove_doozer
Remove Doozer CI
2020-05-03 13:58:29 +02:00
Niels Lohmann
24237af983 🎨 fix format 2020-05-03 13:40:23 +02:00
Niels Lohmann
2f0d37d7d2 🔥 remove fastcov 2020-05-02 23:48:11 +02:00
Niels Lohmann
9c0c58d948 🔥 remove Doozer CI 2020-05-02 23:41:28 +02:00
Niels Lohmann
929f5d398c 🔨 fix coverage tests 2020-05-02 23:24:21 +02:00
Niels Lohmann
752c62b4bd 🔨 remove double tests 2020-05-02 16:07:09 +02:00
Niels Lohmann
f0050c9ba0 Merge pull request #2019 from dota17/contains_v2
fix #1982:json_pointer.contains() exception is incorrectly raised
2020-05-02 11:04:57 +02:00
Niels Lohmann
bec554936c 🔨 fix paths 2020-05-02 10:56:01 +02:00
Niels Lohmann
08c9472184 🔨 simplify workflow 2020-05-01 21:06:41 +02:00
Niels Lohmann
3ae7237f5a 🔨 clean up 2020-05-01 21:01:47 +02:00
Niels Lohmann
cfb2f34ebb 🔨 fix benchmarks 2020-05-01 20:59:47 +02:00
Niels Lohmann
d0ef591ce2 Merge branches 'develop' and 'external_test_data' of https://github.com/nlohmann/json into external_test_data 2020-05-01 20:23:08 +02:00
Niels Lohmann
ec5cfdd307 🔨 properly find and use Git 2020-05-01 16:18:04 +02:00
Niels Lohmann
d144459f1e add git 2020-05-01 16:14:13 +02:00
Niels Lohmann
f58383b8ee 🔊 output on failure 2020-05-01 15:22:18 +02:00
Niels Lohmann
7ade3a0efb remove dependency to FetchContent 2020-05-01 15:14:37 +02:00
Niels Lohmann
dbf1a1f413 ♻️ download test data from external repository 2020-05-01 14:32:37 +02:00
Niels Lohmann
2251741b53 Merge pull request #2077 from ArthurSonzogni/develop-2
Fix README.md. Missing ```
2020-05-01 14:08:59 +02:00
ArthurSonzogni
f26689e006 Fix README.md
About pull request:
https://github.com/nlohmann/json/pull/2074

An error has been introduced by accepting the suggestions:
4be4a038cc

One was about removing ~~~, but it was meant to be replaced by ``` in
reality. This caused the README.md to be slightly broken.
2020-05-01 13:55:24 +02:00
Niels Lohmann
798dbb5c19 📝 add detail 2020-05-01 13:19:49 +02:00
Niels Lohmann
c9f404dc98 Merge pull request #2076 from rmisev/patch-1
Fix error message about invalid surrogate pairs
2020-05-01 12:47:39 +02:00
Niels Lohmann
b27d8a3253 Merge pull request #2074 from ArthurSonzogni/develop
Add CMake fetchcontent documentation and tests
2020-05-01 12:42:29 +02:00
Rimas Misevičius
6f1800889a Fix tests 2020-05-01 00:59:12 +03:00
Rimas Misevičius
4c053e3ec9 Fix tests 2020-05-01 00:48:24 +03:00
Rimas Misevičius
6815968a42 Fix error message about invalid surrogate pairs
I tested following strings with invalid surrogate pair and unpaired surrogate in files:

1. `"a\uD800\uD800x"`
2. `"a\uD800x"`

The error messge was: "... invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; ..."

I think it must be: "... invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF; ..."
2020-05-01 00:23:04 +03:00
Arthur Sonzogni
4be4a038cc Apply suggestions from code review
Co-Authored-By: Niels Lohmann <niels.lohmann@gmail.com>
2020-04-29 21:08:39 +02:00
Niels Lohmann
db013c9428 Merge pull request #2071 from nlohmann/issue2067
Properly pass serialize_binary to dump function
2020-04-29 19:39:58 +02:00
ArthurSonzogni
c331706644 Add CMake fetchcontent documentation and tests
Github issue:
https://github.com/nlohmann/json/issues/2073

nlohmann::json documents 2 way of depending on it using CMake
1) Copy-paste the project/source into your own project.
2) Install nlohman::json and then use find_package.

(1) pollutes your git repository, (2) requires everyone to install the
dependencies themselves.

Since 2018, CMake provide some kind of 'package manager' features using
[FetchContent](https://cmake.org/cmake/help/v3.17/module/FetchContent.html)
It gives the following:
~~~cmake
include(FetchContent)

FetchContent_Declare(json
  GIT_REPOSITORY https://github.com/nlohmann/json
  GIT_TAG v3.7.3)

FetchContent_GetProperties(json)
if(NOT json_POPULATED)
  FetchContent_Populate(json)
  add_subdirectory( ${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
~~~

Then declares the dependency in the target using it:
~~~cmake
target_link_library(my_project PRIVATE nlohmann_json::nlohmann_json
~~~

This patch updates the documentation and provides tests.
2020-04-29 18:28:06 +02:00
Niels Lohmann
b1fe6ee0d1 Merge pull request #2069 from nlohmann/issue2064
Fix returning reference to local temporary object
2020-04-28 20:56:48 +02:00
Niels Lohmann
2e5727d778 🐛 properly pass serialize_binary to dump function #2067 2020-04-27 15:10:23 +02:00
Niels Lohmann
9e0180b698 🐛 fix returning reference to local temporary object #2064 2020-04-27 14:43:49 +02:00
Niels Lohmann
d9d1279a94 Merge pull request #2060 from alexandermyasnikov/develop
updated wandbox link
2020-04-24 09:18:23 +02:00
Alexander Myasnikov
b01bc05b2b updated wandbox link 2020-04-23 13:32:42 +03:00
Niels Lohmann
63afc8e3f8 Merge pull request #2043 from dota17/unit-constructor1
Add missing testcase about NaN in unit-constructor1.cpp
2020-04-21 07:35:44 +02:00
Niels Lohmann
a29e3b1318 Merge pull request #2054 from nlohmann/feature/issue1983
Fix bug in diff function
2020-04-20 19:44:35 +02:00
Niels Lohmann
c0a39b22a6 🚨 fix compiler warning 2020-04-20 19:42:58 +02:00
chenguoping
8bfc692602 update condition 2020-04-20 16:00:55 +08:00
Niels Lohmann
3607687a14 Merge pull request #2053 from nlohmann/gcc10warnings
Fix GCC compiler warnings
2020-04-20 08:05:42 +02:00
Niels Lohmann
721a1a0b5d Merge pull request #2051 from nlohmann/clang10warnings
Fix Clang compiler warnings
2020-04-20 08:04:23 +02:00
Niels Lohmann
f14a7d8af7 Merge pull request #2050 from nlohmann/doctest_update
Update doctest to 2.3.7
2020-04-20 08:02:58 +02:00
chenguoping
c379d02b3e Add missing testcase about NaN in unit-constructor1.cpp 2020-04-20 10:25:44 +08:00
Niels Lohmann
e8356928bd 🚨 fix compiler warnings #2052 2020-04-19 13:25:02 +02:00
Niels Lohmann
4fb0795ec1 🚨 fix compiler warnings #2049 2020-04-19 13:01:36 +02:00
Niels Lohmann
45d5b09425 ⬆️ doctest 2.3.7 #2048 2020-04-19 12:33:42 +02:00
Niels Lohmann
be137609df Merge pull request #1746 from uhoreg/cmake_arch_indep
make CMake's version config file architecture-independent
2020-04-19 10:09:28 +02:00
Hubert Chathi
2b0e4c7a94 add comments 2020-04-17 15:44:12 -04:00
Niels Lohmann
3bc9e053c9 Merge pull request #1969 from dota17/dota17-warning
fix warnings in serializer.hpp for VS2019
2020-04-17 10:10:38 +02:00
Niels Lohmann
69ac336042 Merge pull request #1967 from dota17/dota17-disable
Fix C26451 warnnings in to_chars.hpp
2020-04-17 10:08:21 +02:00
Niels Lohmann
f2b43a36b2 Merge pull request #1662 from OmnipotentEntity/develop
Add binary type support to all binary file formats, as well as an internally represented binary type
2020-04-16 11:14:32 +02:00
Michael Reilly
012c9665ac Add binary type support to all binary file formats, as well as an internally represented binary type 2020-04-14 10:22:45 -04:00
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
7fcc860329 🔥 remove WhiteSource 2020-04-12 16:35:41 +02: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
062fd3842c Merge pull request #2004 from wsjcpp/develop
Added wsjcpp.yml
2020-04-11 11:48:04 +02:00
Niels Lohmann
9154e991b8 Merge branch 'develop' into feature/issue1913 2020-04-11 11:33:46 +02:00
Evgenii Sopov
d164a2bf09 Added wsjcpp.yml: C++ Source Package Manager 2020-04-11 16:30:04 +07:00
Niels Lohmann
6121fc52cf 🎨 fix indentation 2020-04-10 13:22:58 +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
Niels Lohmann
299feb13e7 Merge pull request #1958 from t-b/add-zc-flag-for-msvc
appveyor.yml: Compile and test with latest version for __cplusplus ma…
2020-04-10 13:12:34 +02:00
Artöm Bakri Al-Sarmini
8db02bcc55 Fix for gcc 2020-04-08 15:53:14 +03:00
Artöm Bakri Al-Sarmini
fec0bdd93b still fixing 2020-04-08 00:42:03 +03:00
Artöm Bakri Al-Sarmini
4ce31695f1 Fixed formatting, trying to fix msvc build error in appveyor 2020-04-08 00:26:43 +03:00
Niels Lohmann
c6b298799a 👷 remove failing Travis workers 2020-04-07 09:09:44 +02:00
chenguoping
34cf7b7a48 just restart ci 2020-04-07 10:00:21 +08:00
Thomas Braun
5607dfb48a appveyor.yml: Compile and test with latest version for __cplusplus macro on MSVC
According to [1] the C++ macro __cplusplus has always the value 199711L
even if you enable later version of C++ support via /std.

Use one job with /Zc:__cplusplus defined so that we know that it
compiles.

[1]: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=vs-2019
2020-04-06 11:56:33 +02:00
Niels Lohmann
6a53a95c32 ⬆️ Hedley 13 2020-04-06 11:56:33 +02:00
Niels Lohmann
3884d33c60 Merge pull request #1980 from linev/fix_warning
Rename argument array_index to array_indx in json_pointer methods
2020-04-05 22:00:41 +02:00
Niels Lohmann
554e8c7356 Merge pull request #2002 from alexandermyasnikov/develop
fix error 'setw' is not a member of 'std' in Wandbox example
2020-04-05 21:58:21 +02:00
Niels Lohmann
5c00308de7 Merge pull request #2010 from magamig/patch-1
Update LICENSE.MIT
2020-04-05 21:55:47 +02:00
Niels Lohmann
83e36f314f Merge pull request #2008 from garethsb-sony/implicit-cast-vs2019
PR for #2006 to test in AppVeyor.
2020-04-05 21:53:47 +02:00
Niels Lohmann
379ed1f67e 💰 add sponsor 2020-04-05 15:23:00 +02:00
Artöm Bakri Al-Sarmini
a74a031bba Fix build error 2020-04-02 15:47:08 +03:00
Artöm Bakri Al-Sarmini
e4d8dc02e8 Fixes #1971 (memory leak in basic_json::push_back) 2020-04-02 15:20:25 +03:00
Miguel Magalhães
3df622a417 Update LICENSE.MIT 2020-03-25 17:24:23 +00: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
Alexander Myasnikov
4df7dc04f6 fix error 'setw' is not a member of 'std' in Wandbox example 2020-03-21 18:34:40 +03:00
Sergey Linev
78e911b8c3 Use array_idx as methods args
Avoid mix-up with array_index member

Co-Authored-By: Niels Lohmann <niels.lohmann@gmail.com>
2020-03-19 11:52:40 +01:00
Niels Lohmann
19843b038c Merge pull request #1933 from dota17/dota17-FAQ
Update README.md : add a FAQ about memory release
2020-03-19 11:25:47 +01:00
Niels Lohmann
ebb5a4c09f 💰 add sponsor 2020-03-19 11:14:50 +01:00
chenguoping
bfc003cadf catch exceptions for json_point : /xx/+99 2020-03-17 20:49:28 +08:00
chenguoping
2ccdfebaa7 fix typo 2020-03-14 18:10:55 +08:00
Niels Lohmann
54656ef279 Merge pull request #1956 from dota17/dota17-fix-typo
Fix typo in examples
2020-03-13 17:26:24 +01:00
Niels Lohmann
d102da61ad Merge pull request #1979 from alex-weej/patch-2
README: Fix string representation of `dump`ed `json`
2020-03-13 16:49:13 +01:00
Sergey Linev
00049c20d0 Rename argument array_index to array_indx in json_pointer methods
Fixes gcc48 warning:

declaration of ‘array_index’ shadows a member of 'this' [-Wshadow]
2020-03-11 07:41:53 +01:00
Alexander “weej” Jones
5fdb1d08aa README: Fix string representation of dumped json
As is it's confusing and inconsistent with the indented form right below. The backslash escapes make it confusing.
2020-03-10 19:37:20 +00:00
Francois Chabot
41b0704ce1 removed move assignments from input adapters 2020-03-02 23:50:01 -05:00
Francois Chabot
7eadd6daef added back forward declaration to address warnings 2020-02-28 18:15:11 -05:00
dota17
699e0a923c fix typo in examples 2020-02-26 13:44:08 +08: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
Chen
42566c6bef Update README.md 2020-02-17 15:40:52 +08:00
Niels Lohmann
61b46a56fb 🏗️ replace is_pod by is_trivial 2020-02-15 10:12:27 +01:00
Chen
88097a250f Update README.md : add a FAQ about memory release 2020-02-10 21:03:57 +08:00
Niels Lohmann
973c52dd4a Merge pull request #1923 from Coeur/typos
Some typos
2020-02-02 14:48:07 +01:00
Antoine Cœur
8d92ca865f Some typos 2020-02-02 17:29:37 +08:00
Niels Lohmann
6a6790ab68 Merge pull request #1917 from jothepro/update-links-to-hunter
Readme: Updated links to hunter repo & docs
2020-01-31 11:47:42 +01:00
Niels Lohmann
3eb6b0e7a2 Merge pull request #1918 from kastiglione/patch-1
Fix link to parse function in README
2020-01-31 11:46:53 +01:00
Dave Lee
f25a1287f9 Fix link to parse function in README 2020-01-29 14:19:00 -08:00
jothepro
0257533866 Updated links to hunter repo & docs
hunter was recently passed over to a new maintainer, this is why the github url & the link to the documentation have changed.
2020-01-29 22:33:59 +01:00
Niels Lohmann
6ca5338a0c Merge pull request #1909 from Klaim/patch-1
Adds instruction for using Build2's package manager
2020-01-28 19:00:45 +01:00
Joël Lamotte
ab538ba523 Formatting
(proper naming suggested by `build2`'s author)
2020-01-21 17:49:23 +01:00
Joël Lamotte
708e107d8e Adds instruction for using Build2's package manager
I created a `nlohmann-json` package for `build2` (https://build2.org) that have been published on the central public repository https://cppget.org : https://cppget.org/nlohmann-json (at the moment you can see that there is only one version: 3.7.3).

The repository of the package code is there: https://github.com/build2-packaging/nlohmann-json and is owned by the build2 community now. (with build2 you can use either a repository like cppget.org or a git repository so both are useful to users for different use cases).

This patch just add the basic information as to how to use this library with build2.
2020-01-20 14:50:15 +01:00
Niels Lohmann
ad383f66bc Merge pull request #1907 from pauljurczak/patch-1
Update README.md
2020-01-19 22:45:53 +01:00
Paul Jurczak
bc95563814 Update README.md 2020-01-18 14:25:03 -07: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
Niels Lohmann
bde5712418 Merge pull request #1871 from sonulohani/develop
Fix warning: ignoring return value
2019-12-16 15:06:47 +01:00
Sonu Lohani
4c1ebb4413 Fix warning: ignoring return value 2019-12-16 14:22:41 +05:30
Niels Lohmann
b568619c4a 💰 add sponsor section 2019-12-15 19:26:51 +01:00
Niels Lohmann
bccc8f0577 Merge pull request #1857 from gocarlos/develop
docs: add central repository as conan source to readme
2019-12-01 11:53:24 +01:00
Carlos Gomes Martinho
ac9df48453 style: format readme 2019-12-01 10:23:24 +01:00
Carlos Gomes Martinho
f44e8ac090 revert: adding conan badge 2019-12-01 10:22:48 +01:00
Carlos Gomes Martinho
134a5faa2b docs: add central repository as conan source to readme 2019-11-29 13:49:53 +01:00
Niels Lohmann
c3270ac734 Merge pull request #1853 from podsvirov/readme-msys2-package-rename
README: Package in MSYS2 renamed to nlohmann-json
2019-11-23 09:21:52 +01:00
Konstantin Podsvirov
f586bc014f README: Package in MSYS2 renamed to nlohmann-json
This is done to correctly match with the
corresponding package in Archlinux.
2019-11-23 05:02:20 +03:00
Niels Lohmann
c0f52edbc3 📝 add badges 2019-11-22 21:17:31 +01:00
Niels Lohmann
a4c01f3380 👥 add GitHub Sponsors 2019-11-22 20:58:44 +01:00
Niels Lohmann
3f044dad81 📝 add Xocde 11.2.1 to CI list 2019-11-22 08:00:41 +01:00
Niels Lohmann
28b1448508 👷 add Xcode 11.2.1
https://twitter.com/travisci/status/1197625080119021568
2019-11-21 22:22:06 +01:00
Niels Lohmann
7439cfe5c8 Merge pull request #1844 from Tridacnid/develop
Update tests that generate CMake projects to use main project's C++ compiler
2019-11-19 19:27:14 +01:00
Niels Lohmann
b2bec943d1 Merge pull request #1846 from Mike-Bal/fix_warnings
Fix msvc warnings
2019-11-19 19:24:36 +01:00
Michael Balszun
25e0175bc3 Remove unnecessary warning suppressions in test cmake file 2019-11-19 11:26:35 +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
Joe Burzinski
fbb0bd7556 Update tests that generate CMake projects to use the CMAKE_CXX_COMPILER the main project was CMake'd with. Fixes #1747. 2019-11-18 21:46:34 -06:00
Niels Lohmann
e7b3b40b5a Merge branch 'release/3.7.3' into develop 2019-11-17 12:21:44 +01:00
Niels Lohmann
c5eafe74e8 🔖 set version to 3.7.3 2019-11-17 12:09:12 +01:00
Niels Lohmann
c6e1e26018 Merge pull request #1838 from nickaein/fix-quadratic-destruction
Fix quadratic destruction complexity
2019-11-15 07:02: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
411158d896 Merge branch 'release/3.7.2' into develop 2019-11-10 21:39:14 +01:00
Niels Lohmann
56109eacd7 🔖 set version to 3.7.2 2019-11-10 21:23:39 +01:00
Niels Lohmann
7b0c50b9a5 🔨 add path 2019-11-10 19:09:48 +01:00
Niels Lohmann
0a513a35cb Merge pull request #1436 from nickaein/iterate-on-destruction
Prevent stackoverflow caused by recursive deconstruction
2019-11-10 11:57:06 +01:00
Isaac Nickaein
7e2445a0f4 Move deep JSON test to a separate unit-test 2019-11-09 21:42:39 +03:30
Isaac Nickaein
68d0a7b246 Reduce depth in unit-test to avoid choking valgrind 2019-11-09 21:19:12 +03:30
Isaac Nickaein
eec1974218 Merge remote-tracking branch 'nlohmann/develop' into iterate-on-destruction 2019-11-09 14:50:48 +03:30
Niels Lohmann
67259d698f Merge pull request #1830 from nlohmann/whitesource/configure
Configure WhiteSource Bolt for GitHub
2019-11-08 14:04:27 +01:00
whitesource-bolt-for-github[bot]
760076abca Add .whitesource configuration file 2019-11-08 13:01:29 +00:00
Niels Lohmann
1a9de88117 🚨 fix a linter warning
Coverity detected two "Memory - illegal accesses  (OVERRUN)" issues. Resizing the buffer should silence this warning.
2019-11-07 08:00:21 +01:00
Niels Lohmann
d98bf0278d Merge branch 'release/3.7.1' into develop 2019-11-06 20:34:07 +01:00
Niels Lohmann
aacdc6bbe3 🔖 set version to 3.7.1 2019-11-06 18:37:26 +01:00
Niels Lohmann
0f6a58eeaf 👥 update contributors 2019-11-06 17:35:04 +01:00
Niels Lohmann
1e9f16dff0 🚨 fix linter errors 2019-11-05 20:25:53 +01:00
Niels Lohmann
c0ae88bf50 🚨 fix linter errors 2019-11-05 20:23:17 +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
Niels Lohmann
1ca6f2901b Merge pull request #1826 from cbegue/develop
Add restriction for tuple specialization of to_json
2019-11-05 19:14:37 +01:00
Niels Lohmann
abccafa5c5 ⬆️ upgrade Doctest to 2.3.5 2019-11-05 19:11:54 +01:00
Anthony VH
c4923e3d05 Merge remote-tracking branch 'upstream/develop' into develop 2019-11-04 20:50:43 +01:00
Anthony VH
ec9647ae63 Moved test for #1647 regression to regressions file. 2019-11-04 20:45:24 +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
3790bd9ae0 👷 add Xcode 10.2 2019-11-04 06:22:39 +01:00
Niels Lohmann
42e9ad32c6 🔨 remove full path 2019-11-03 21:49:22 +01:00
Niels Lohmann
e779714dd8 👷 add Xcode 10.2 2019-11-03 20:45:21 +01:00
Niels Lohmann
bf2afaeee6 🔊 add version output 2019-11-03 20:27:07 +01:00
Niels Lohmann
6a4cc29f01 📝 update examples 2019-11-03 19:40:38 +01:00
Niels Lohmann
dfe53c36da 🚨 fix UBSAN warnings 2019-11-03 13:48:25 +01:00
Niels Lohmann
0db1692f45 👥 update contributors 2019-11-02 10:24:06 +01:00
Niels Lohmann
1307862b1d Merge pull request #1694 from eli-schwartz/release-include-meson
release: add singleinclude and meson.build to include.zip
2019-11-02 09:28:51 +01:00
Niels Lohmann
4d1e4c6d93 Merge pull request #1780 from t-b/add-msvc-16-2019
appveyor.yml: Add MSVC 16 2019 support
2019-11-02 08:16:53 +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
fb9a2643c8 Add test for #1647. 2019-10-30 15:46:31 +01:00
Anthony Van Herrewege
27d0dfc17a Fix #1647: non-member operator== breaks enum (de)serialization. 2019-10-30 14:54:52 +01:00
Niels Lohmann
f272ad533d 👥 add CODEOWNERS file 2019-10-23 21:41:12 +02:00
Niels Lohmann
f7e7a62358 📝 add comment on JSON_THROW_USER, JSON_TRY_USER, and JSON_CATCH_USER 2019-10-23 20:58:06 +02:00
Niels Lohmann
507d5676ad 🚨 fix warning 2019-10-23 20:57:10 +02:00
Niels Lohmann
00cb98a3d1 Merge pull request #1803 from flopp/spelling
Fix some spelling errors - mostly in comments & documentation.
2019-10-21 20:50:13 +02: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
Eli Schwartz
f4332d4097 README: describe how to use json as a meson subproject
Also call out to the guidelines for using pkg-config dependencies first,
and reference it for other build systems as well.

Although the possibility of installing with a pkg-config file is
somewhat hidden away in the meson docs, it's been deemed less invasive
due to not distracting away from cmake. So it will have to do.
2019-10-17 15:38:06 -04:00
Eli Schwartz
84faa36ec5 release: add singleinclude and meson.build to include.zip
This serves as a minimal release-only way to embed json into a project.
Add meson support to this directly, to make it usable standalone as a
meson subproject.

Implements #1672
2019-10-17 15:26:51 -04: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
Niels Lohmann
4c06191836 Merge pull request #1799 from nemequ/develop
Update Hedley to v11.
2019-10-17 20:59:49 +02:00
Evan Nemerson
fbcbc76d10 Update Hedley to v11. 2019-10-16 13:39:40 -07:00
Thomas Braun
c6cbdf96a9 appveyor.yml: Add debug build on x64 and VS 2019 2019-10-16 22:34:33 +02:00
Thomas Braun
01e486bb55 appveyor.yml: Add MSVC 16 2019 support 2019-10-16 22:34:33 +02: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
Thomas Braun
5541a2bd25 test/cmake_import: Pass the generator platform required by MSVC 2019 2019-10-16 17:10:19 +02:00
Thomas Braun
7a521150aa appveyor: Pass the generator platform explicitly
In a future commit we want to add support for MSVC 2019. For that
version cmake requires us to pass in the architecture not part of the
generator but explicitly.

So let's pass that in always like that. This also removes the doubling
of the platform/architecture.
2019-10-16 17:10:19 +02:00
Niels Lohmann
ed5541440a Merge pull request #1779 from t-b/avoid-using-glob-in-cmake
test/CMakeLists.txt: Use an explicit list instead of GLOB
2019-10-09 07:37:43 +02:00
Thomas Braun
eb6fe421ae test/CMakeLists.txt: Use an explicit list instead of GLOB
Using GLOB is slow and considered bad practice.

From https://cmake.org/cmake/help/latest/command/file.html:

> We do not recommend using GLOB to collect a list of source files from
> your source tree. If no CMakeLists.txt file changes when a source is
> added or removed then the generated build system cannot know when to ask
> CMake to regenerate. The CONFIGURE_DEPENDS flag may not work reliably on
> all generators, or if a new generator is added in the future that cannot
> support it, projects using it will be stuck. Even if CONFIGURE_DEPENDS
> works reliably, there is still a cost to perform the check on every
> rebuild.
2019-10-07 21:13:09 +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
Niels Lohmann
dae0fe79af Merge pull request #1769 from chris0x44/json_pointer
Make json_pointer::back const (resolves #1764)
2019-10-03 10:35:34 +02:00
Niels Lohmann
d826282f53 Merge pull request #1767 from 0xflotus/patch-1
did you mean 'serialization'?
2019-10-01 11:32:05 +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
0xflotus
d7579b8cbf did you mean 'serialization'? 2019-09-30 18:11:44 +02:00
Julien Hamaide
0f073e26eb Allow items() to be used with custom string 2019-09-26 13:20:57 +02:00
Niels Lohmann
99d7518d21 📝 add OSS Fuzz status badge 2019-09-24 21:01:06 +02:00
Niels Lohmann
e2c531a1f7 Merge pull request #1760 from Xav83/cppcheckFixes
Cppcheck fixes
2019-09-24 20:42:38 +02:00
Xav83
87afee1c39 Runs make amalgamate on the project. 2019-09-20 11:45:38 +02:00
Xav83
13a7c60257 Correct a warning from cppcheck:
binary_writer.hpp:869: (style) Consider using std::accumulate algorithm instead of a raw loop.

910a7d2b87/checks (step):5:107

Signed-off-by: Xav83 <x.jouvenot@gmail.com>
2019-09-20 11:45:38 +02:00
Xav83
b9dfdbe6be Correct a warning from cppcheck:
binary_reader.hpp:650: (style) Unsigned expression 'mant' can't be negative so it is unnecessary to test it

910a7d2b87/checks (step):5:84

Signed-off-by: Xav83 <x.jouvenot@gmail.com>
2019-09-19 19:25:55 +02:00
Niels Lohmann
771d5dadc6 Merge pull request #1741 from tete17/Fix-SFINAE
Fix and add test's for SFINAE problem
2019-09-16 22:39:42 +02:00
Hubert Chathi
cade804c1a make CMake's version config file architecture-independent 2019-09-10 23:41:38 -04: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
Niels Lohmann
a6bd798bfa Merge pull request #1728 from t-b/fix-clang-sanitizer-invocation
Fix clang sanitizer invocation
2019-09-10 07:50:02 +02:00
Thomas Braun
8067c3ca5b Add serialization unit tests for extreme integer values 2019-09-03 13:55:19 +02:00
Thomas Braun
70aa8a31a2 Add regression test for dumping the minimum value of int64_t 2019-09-03 13:55:19 +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
6d701b29df .travis.yml: Increase the timeout to 45 minutes
The clang sanitizer tests, and there especially the unicode tests, can
hit the default timeout of 25 minutes (1500 seconds) quite easily, so
let's raise the timeout to 45 minutes (2700 seconds).
2019-09-03 13:32:25 +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
Thomas Braun
9ea3e19121 .travis/cmake: Rework clang sanitizer invocation
- Switch to clang-7
- Adapt PATH so that llvm-symbolizer can be found for useful stacktraces
- Adapt compile flags
  "-O0" ensures much faster compile times
  "-fno-sanitize-recover=all
  -fsanitize-recover=unsigned-integer-overflow" this fails the build on
  all issues except unsigned integer overflows. Not failing in this case
  is required in combination with the sanitizer suppression file as only
  recoverable errors can be suppressed.

The UBSAN suppression file ignores errors from stl_bvector.h (which
holds std::vector<bool>).

Clang reports that error as

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20 in

      Start 34: test-deserialization_all
28/88 Test #71: test-testsuites_default .............***Failed    0.32 sec
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
    #0 0x628f72 in std::_Bit_iterator_base::_M_bump_down() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:158:20
    #1 0x628d16 in std::_Bit_iterator::operator--() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:251:7
    #2 0x634aac in std::vector<bool, std::allocator<bool> >::pop_back() /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/stl_bvector.h:1010:7
    #3 0x61eff0 in bool nlohmann::detail::parser<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> >::sax_parse_internal<nlohmann::detail::json_sax_dom_parser<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> > >(nlohmann::detail::json_sax_dom_parser<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> >*) /home/firma/devel/json/include/nlohmann/detail/input/parser.hpp:439:28
    #4 0x604864 in nlohmann::detail::parser<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> >::parse(bool, 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>&) /home/firma/devel/json/include/nlohmann/detail/input/parser.hpp:116:13
    #5 0x5f8079 in nlohmann::operator>>(std::istream&, 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>&) /home/firma/devel/json/include/nlohmann/json.hpp:6356:42
    #6 0x5e1d92 in _DOCTEST_ANON_FUNC_21() /home/firma/devel/json/test/src/unit-testsuites.cpp:343:9
    #7 0x7207fe in doctest::Context::run() /home/firma/devel/json/test/thirdparty/doctest/doctest.h:5938:21
    #8 0x72681a in main /home/firma/devel/json/test/thirdparty/doctest/doctest.h:6016:71
    #9 0x7f75d22362e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #10 0x4c28b9 in _start (/home/firma/devel/json/build/test/test-testsuites+0x4c28b9)

The pop_back() in parser.hpp

      assert(not states.empty());
  ->  states.pop_back();

triggers the UBSAN report. But the assertion above ensure that we only
call pop_back() on an non-empty vector, therefore this is a STL library
bug and thus must be ignored for us.
2019-09-03 13:22:03 +02:00
Thomas Braun
f0bff49ffd test/CMakeLists.txt: Remove trailing whitespace 2019-09-03 13:22:03 +02:00
Niels Lohmann
eab68e7750 👷 add test step 2019-09-02 22:15:11 +02:00
Niels Lohmann
90c1c24ccb 👷 try GitHub Actions 2019-09-02 21:35:53 +02:00
Niels Lohmann
bf4156056b ✏️ fix a typo 2019-08-27 20:18:04 +02:00
Niels Lohmann
b6ee34cc99 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-08-27 20:03:05 +02:00
Niels Lohmann
7dccfa5355 Merge pull request #1724 from t-b/enhance-travis
Add gcc 9 and compile with experimental C++20 support
2019-08-27 19:57:23 +02:00
Thomas Braun
a4eaaa56d1 .travis.yml: Add gcc 9 and compile with experimental C++20 support 2019-08-26 12:38:36 +02:00
Niels Lohmann
fe618ac246 👷 adjust maintainer scripts 2019-07-29 18:49:21 +02:00
Niels Lohmann
a015b78e81 🔒 add security policy 2019-07-28 21:46:32 +02:00
Niels Lohmann
6291803f59 👥 update contributors 2019-07-28 21:31:17 +02:00
Niels Lohmann
53c3eefa2c Merge branch 'release/3.7.0' into develop 2019-07-28 21:23:36 +02:00
Niels Lohmann
d275d05514 📝 update documentation 2019-07-28 20:54:02 +02:00
Niels Lohmann
ddb7f70a12 📝 update documentation 2019-07-28 20:53:18 +02:00
Niels Lohmann
48e1fe03b5 🔖 set version to 3.7.0 2019-07-28 20:20:41 +02:00
Niels Lohmann
66d63abe6d Update Makefile 2019-07-28 18:40:11 +02:00
Niels Lohmann
d4fd731f1f 🔨 fix release target 2019-07-28 17:55:01 +02:00
Niels Lohmann
d80f8b09f5 🔨 adjust version 2019-07-28 15:20:07 +02:00
Niels Lohmann
7bf8a86090 🔨 adjust paths 2019-07-28 14:30:17 +02:00
Niels Lohmann
65e4b973bd 🔥 remove leftover file 2019-07-21 14:10:37 +02:00
Niels Lohmann
323cf95d8c 🚨 fix linter warning 2019-07-21 14:04:49 +02:00
Niels Lohmann
ffe0e3d70f Merge pull request #1673 from remyabel/gnuinstalldirs
Use GNUInstallDirs instead of hard-coded path.
2019-07-17 06:28:38 +02:00
Tommy Nguyen
3184e9bd8b Use GNUInstallDirs instead of hard-coded path. 2019-07-16 11:44:32 -04:00
Niels Lohmann
cf8251eb54 🚑 fix compiler errors 2019-07-14 21:19:55 +02:00
Niels Lohmann
6c7cde181c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-07-14 20:58:29 +02:00
Niels Lohmann
a501365ea2 Merge branch 'feature/hedley' into develop 2019-07-14 20:58:08 +02:00
Niels Lohmann
8d059b96a1 Merge pull request #1670 from podsvirov/readme-package-managers-msys2
Package Manager: MSYS2 (pacman)
2019-07-13 17:58:08 +02:00
Konstantin Podsvirov
6a3cdb281e Package Manager: MSYS2 (pacman)
Add a package installation instructions for MSYS2 software distro.
2019-07-12 22:27:17 +03: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
24fa285edb 📝 remove HEDLEY annotation from documentation 2019-07-02 21:15:52 +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
kevinlul
e616d095ab Remove boolean regression test for #1642 2019-06-30 11:57:57 -04: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
kevinlul
855156b5e8 Add regression tests for #1642 2019-06-29 19:26:38 -04:00
Niels Lohmann
9a775bcb14 Merge pull request #1570 from nickaein/msvc-regression-tests
Regression tests for MSVC
2019-06-25 07:05:53 +02:00
Isaac Nickaein
5b2e2305a0 CI: Skip test-unit_all on MSVC Debug builds 2019-06-24 21:21:58 +04:30
Isaac Nickaein
3db14cbfae 📝 Improve doc on const_inter constructor 2019-06-24 15:40:01 +04:30
Isaac Nickaein
0a137b78ac Appveyor: Set timeout of unit-tests in appveyor.yml instead of CMake 2019-06-22 22:14:40 +04:30
Isaac Nickaein
f559142008 Appveyor: Set build mode explicitly 2019-06-22 21:15:17 +04:30
Isaac Nickaein
eba8244ead Avoid collision of ::max with windows.h macro 2019-06-22 21:15:13 +04:30
Isaac Nickaein
798e83a038 Workaround msvc2015 bug with explicit copy-constructor for const_iterator 2019-06-22 21:15:11 +04:30
Isaac Nickaein
d28b4b900e Add a separate build with Windows.h included 2019-06-22 21:15:07 +04:30
Isaac Nickaein
4ac0fe2628 Increase timeout of test-unicode_all in Debug build 2019-06-22 21:15:03 +04:30
Isaac Nickaein
ec43d27f9f Add Debug builds for AppVeyor 2019-06-22 21:14:51 +04:30
Niels Lohmann
39011a1759 📝 mention json type in documentation start page #1616 2019-06-22 09:54:59 +02:00
Niels Lohmann
3b82a350ed 📝 mention 302 exception in value() documentation #1601 2019-06-22 09:44:12 +02:00
Niels Lohmann
13d4f8f5ad Merge pull request #1639 from taylorhoward92/develop
Add explicit conversion from json to std::string_view in conversion unit test
2019-06-22 09:25:02 +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
Taylor Howard
2f389cdde7 Added explicit converstion to std::string_view. Fixes failing test with GCC 8.3 2019-06-16 14:49:01 +10:00
Niels Lohmann
4fc98e0b34 Merge pull request #1625 from nickaein/fix-docs
Minor fixes in docs
2019-06-05 20:25:48 +02:00
Isaac Nickaein
0c214949f5 ✏️ Fix links to create an issue page 2019-06-04 11:27:25 +04:30
Isaac Nickaein
b22c577e83 ✏️ Fix brew instructions in README 2019-06-04 11:25:44 +04:30
Isaac Nickaein
0d55ddc5bf ✏️ Fix a typo in README 2019-06-04 11:24:22 +04:30
Niels Lohmann
17c0849a63 Merge pull request #1585 from Macr0Nerd/iss916
Added to_string and added basic tests
2019-05-24 09:20:15 +02:00
Niels Lohmann
9f2179deb1 Merge pull request #1598 from nickaein/patch-2
Fix broken links to documentation
2019-05-24 09:16:38 +02:00
Isaac Nickaein
40c3d5024a Fix broken links to documentation
Fixes #1597 and some other links
2019-05-12 22:04:01 +04:30
Macr0Nerd
26952500b8 Merge branch 'iss916' of https://github.com/Macr0Nerd/json into iss916 2019-04-26 18:15:52 -05:00
Macr0Nerd
aa4c45ee4d Added to_string (with ugly macro) and tests 2019-04-26 18:10:45 -05:00
Macr0Nerd
293cd6b794 Added to_string and added basic tests 2019-04-25 22:12:15 -05:00
Niels Lohmann
ee4028b8e4 Merge branch 'feature/fastcov' into develop 2019-04-06 09:15:43 +02:00
Niels Lohmann
cf6b6692aa Merge branch 'develop' into feature/fastcov 2019-04-06 09:03:35 +02:00
Niels Lohmann
f0bc16d899 🔨 overworked coverage targets 2019-04-06 09:02:17 +02:00
Niels Lohmann
b4b06d89b5 ⬆️ updated fastcov 2019-04-06 00:24:19 +02:00
Niels Lohmann
e65cff2a8f 🔨 small cleanup 2019-04-05 23:31:04 +02:00
Niels Lohmann
63fe1cbbcf 📝 updated README 2019-04-05 18:29:57 +02:00
Niels Lohmann
0bdadb12c7 Merge branch 'feature/circleci' into develop 2019-04-05 17:50:48 +02:00
Niels Lohmann
0a1ddd6882 ⬆️ updated fastcov 2019-04-05 07:54:46 +02:00
Niels Lohmann
4676f759e8 ⬆️ updated fastcov 2019-04-04 09:50:27 +02:00
Niels Lohmann
da279234d5 Merge branch 'develop' into feature/fastcov 2019-04-04 09:03:11 +02:00
Niels Lohmann
f05614b240 🏗️ adding anonymous namespace 2019-04-04 08:56:36 +02:00
Niels Lohmann
0da99027b7 🚨 silenced a warning 2019-04-03 17:44:09 +02:00
Niels Lohmann
1f03395e2c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2019-04-03 17:28:50 +02:00
Niels Lohmann
2f9095ddab 🔨 relaxed requirements to coverage 2019-04-03 17:28:47 +02:00
Niels Lohmann
ee8732c359 Merge pull request #1555 from theodelrieu/fix/1511
Fix/1511
2019-04-03 17:24:25 +02:00
Niels Lohmann
d1ef75316e Merge pull request #1439 from onqtam/doctest
moved from Catch to doctest for unit tests
2019-04-03 17:01:48 +02:00
Théo DELRIEU
d66abda4ee tests: fix coverage 2019-04-03 12:34:15 +02: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
onqtam
da5b7833a0 fixing the remaining of the pedantic gcc/clang target warnings 2019-03-31 13:57:44 +03:00
Viktor Kirilov
64873fb5b8 Merge branch 'develop' into doctest 2019-03-30 23:23:33 +02:00
Niels Lohmann
80daa19331 👷 Ninja seems not to work 2019-03-30 17:39:50 +01:00
Niels Lohmann
0a57c51a69 👷 adding concurrency 2019-03-30 17:32:52 +01:00
Niels Lohmann
a5e00f2cf7 👷 fixed path 2019-03-30 17:19:27 +01:00
Niels Lohmann
5ebe722045 👷 full workflow 2019-03-30 17:14:50 +01:00
Niels Lohmann
ecf4d5e91d 👷 trying CircleCI 2019-03-30 17:05:43 +01:00
Niels Lohmann
53001414c7 🔨 using --exclude-gcov to exclude files 2019-03-30 17:00:30 +01:00
Niels Lohmann
b12287b362 ⚗️ trying fastcov 2019-03-30 09:12:32 +01:00
Niels Lohmann
b21c04c938 🔥 removed unsupported flag 2019-03-29 17:34:58 +01:00
Niels Lohmann
c7878173f9 🔨 minor changes to maintainer targets 2019-03-29 13:10:11 +01: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
Niels Lohmann
23635704c3 ⬆️ added script to update cpplint 2019-03-28 14:23:07 +01:00
Niels Lohmann
191aa0fd6f 🔧 overworked maintaner targets 2019-03-28 14:22:48 +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
onqtam
b4def6dcba tabs instead of spaces... 2019-03-27 01:13:10 +02:00
onqtam
a0000c3235 finished the last of the warnings 2019-03-27 01:09:47 +02:00
onqtam
5d511a6e96 fixed a bunch of warnings from the Makefile from the root of the repo 2019-03-27 00:58:53 +02:00
Viktor Kirilov
82af0ecdc1 Merge branch 'develop' into doctest 2019-03-26 23:32:32 +02:00
Niels Lohmann
d79c16801a Merge branch 'feature/doozer' into develop 2019-03-26 10:49:56 +01:00
Niels Lohmann
24d91cf36f 📝 added Doozer to README 2019-03-26 10:49:14 +01:00
Niels Lohmann
0991824584 👷 version output 2019-03-26 10:41:05 +01:00
onqtam
0caf986505 reverted the removal of this if/else branching - this is the easiest way to get -std=c++0x support 2019-03-25 22:04:37 +02:00
Niels Lohmann
9d2f0391e0 👷 fixed timeout 2019-03-25 12:30:45 +01:00
Niels Lohmann
af9da22b87 👷 adding xenial-armhf 2019-03-25 07:15:03 +01:00
Niels Lohmann
0a67b51fce 👷 forgot path to ctest 2019-03-25 07:03:41 +01:00
Niels Lohmann
e27b282033 👷 skip certificate check 2019-03-25 06:45:35 +01:00
Niels Lohmann
cde0b24389 👷 fixed required packages 2019-03-25 06:43:14 +01:00
Niels Lohmann
f091fe31bc 👷 increased timeout 2019-03-25 06:39:41 +01:00
Niels Lohmann
28dfbedda7 👷 fixed timeout 2019-03-24 18:14:59 +01:00
onqtam
ff51a32be1 updated doctest to version 2.3.1 released today 2019-03-24 17:28:52 +02:00
onqtam
2b346099df Merge branch 'develop' of https://github.com/nlohmann/json into doctest 2019-03-24 17:21:44 +02:00
Niels Lohmann
dcbc028b5b 👷 fixed syntax 2019-03-24 09:02:46 +01:00
Niels Lohmann
842d42b135 👷 unified paths 2019-03-24 09:02:06 +01:00
Niels Lohmann
1e86976cfe 👷 fixed paths 2019-03-24 08:53:30 +01:00
Niels Lohmann
30211477b7 👷 fixed package name 2019-03-24 08:36:01 +01:00
Niels Lohmann
5e1cae0a7d 👷 install g++ 2019-03-24 08:24:50 +01:00
Niels Lohmann
c871c9a01c 👷 install correct g++ 2019-03-24 06:51:10 +01:00
Niels Lohmann
63d619e21f 👷 need to install g++ 2019-03-24 00:48:59 +01:00
Niels Lohmann
c94b764a6e 👷 fixed installation 2019-03-24 00:43:01 +01:00
Niels Lohmann
65cdccfa8a 👷 fixed syntax error 2019-03-24 00:36:46 +01:00
Niels Lohmann
a72ac18514 👷 use recent cmake 2019-03-24 00:36:05 +01:00
Niels Lohmann
4327ae0bef 👷 need more recent cmake for CentOS 2019-03-24 00:15:57 +01:00
Niels Lohmann
fabf953305 👷 fixed a typo 2019-03-24 00:12:36 +01:00
Niels Lohmann
6e3e2ee2e4 👷 fixed buildenv values 2019-03-24 00:11:20 +01:00
Niels Lohmann
bc5089e803 👷 add test output to avoid timeout 2019-03-24 00:02:41 +01:00
Niels Lohmann
7dd3e6384b 👷 added Fedora and CentOS 2019-03-23 23:42:29 +01:00
Niels Lohmann
490c6e926e 👷 using raspbian 2019-03-23 23:27:39 +01:00
Niels Lohmann
2fcca259b0 👷 added cmake 2019-03-23 23:21:17 +01:00
Niels Lohmann
72dd6f349e 👷 trying doozer 2019-03-23 23:18:27 +01:00
Niels Lohmann
baaa2a4d0f 🏁 trying to use constructors from std::allocator #1536 2019-03-21 14:09:29 +01:00
Viktor Kirilov
155d196bfa Update CMakeLists.txt 2019-03-18 17:58:35 +02:00
Viktor Kirilov
365944b0bc Merge branch 'develop' into doctest 2019-03-18 16:59:36 +02:00
Isaac Nickaein
372c4d2125 Merge branch 'develop' into iterate-on-destruction 2019-01-28 02:41:22 +03:30
onqtam
a2c074fd4d this should really fix the XCode 6/7 builds 2019-01-15 22:58:12 +02:00
onqtam
3340162efd fixing osx builds - had forgotten to define this for the object file where the test runner is compiled 2019-01-15 22:48:37 +02:00
onqtam
2f44ac1def moved from Catch to doctest for unit tests 2019-01-15 22:02:16 +02:00
Isaac Nickaein
f0883dda8f During destruction, flatten children of objects to avoid recursion 2019-01-15 20:29:51 +03:30
Isaac Nickaein
47fe4b9cee Add unit test for parsing deeply-nested array 2019-01-15 20:22:11 +03:30
1434 changed files with 27332 additions and 6312868 deletions

48
.circleci/config.yml Normal file
View File

@@ -0,0 +1,48 @@
version: 2
jobs:
build_stable:
docker:
- image: debian:stretch
steps:
- checkout
- run:
name: Install required tools
command: 'apt-get update && apt-get install -y gcc g++ git cmake'
- run:
name: Run CMake
command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run:
name: Compile
command: 'cmake --build build'
- run:
name: Execute test suite
command: 'cd build ; ctest --output-on-failure -j 2'
build_bleeding_edge:
docker:
- image: archlinux
steps:
- checkout
- run:
name: Install required tools
command: 'pacman -Sy --noconfirm base base-devel gcc git cmake'
- run:
name: Run CMake
command: 'mkdir build ; cd build ; cmake .. -DJSON_BuildTests=On'
- run:
name: Compile
command: 'cmake --build build'
- run:
name: Execute test suite
command: 'cd build ; ctest --output-on-failure -j 2'
workflows:
version: 2
build_and_test_all:
jobs:
- build_stable
- build_bleeding_edge

View File

@@ -4,14 +4,17 @@ Checks: '-*,
clang-analyzer-*,
google-*,
-google-runtime-references,
-google-explicit-constructor,
hicpp-*,
-hicpp-no-array-decay,
-hicpp-uppercase-literal-suffix,
-hicpp-explicit-conversions,
misc-*,
-misc-non-private-member-variables-in-classes,
llvm-*,
-llvm-header-guard,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,

6
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,6 @@
# JSON for Modern C++ has been originally written by Niels Lohmann.
# Since 2013 over 140 contributors have helped to improve the library.
# This CODEOWNERS file is only to make sure that @nlohmann is requested
# for a code review in case of a pull request.
* @nlohmann

View File

@@ -4,7 +4,7 @@
This project started as a little excuse to exercise some of the cool new C++11 features. Over time, people actually started to use the JSON library (yey!) and started to help improve it by proposing features, finding bugs, or even fixing my mistakes. I am really [thankful](https://github.com/nlohmann/json/blob/master/README.md#thanks) for this and try to keep track of all the helpers.
To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new) or a pull request if you find a way to improve it!
To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new/choose) or a pull request if you find a way to improve it!
## Private reports
@@ -12,7 +12,7 @@ Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann
## Prerequisites
Please [create an issue](https://github.com/nlohmann/json/issues/new), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
Please [create an issue](https://github.com/nlohmann/json/issues/new/choose), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
## Describe your issue
@@ -22,7 +22,7 @@ Clearly describe the issue:
- If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it.
- If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket.
Please stick to the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) if possible.
Please stick to the provided issue templates ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Bug_report.md), [feature request](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Feature_request.md), or [question](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/question.md)) if possible.
## Files to change
@@ -32,7 +32,7 @@ To make changes, you need to edit the following files:
1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp`.
2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code.
If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with
@@ -56,7 +56,7 @@ To make changes, you need to edit the following files:
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- We shall not extend the library to **support comments**. There is quite some [controversy](https://www.reddit.com/r/programming/comments/4v6chu/why_json_doesnt_support_comments_douglas_crockford/) around this topic, and there were quite some [issues](https://github.com/nlohmann/json/issues/376) on this. We believe that JSON is fine without comments.
- We do not preserve the **insertion order of object elements**. The [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". To this end, this library does not preserve insertion order of name/value pairs. (In fact, keys will be traversed in alphabetical order as `std::map` with `std::less` is used by default.) Note this behavior conforms to the standard, and we shall not change it to any other order. If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map).
@@ -66,6 +66,6 @@ To make changes, you need to edit the following files:
The following areas really need contribution:
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions of GCC or Clang.
- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions Clang.
- Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for parsing.
- Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency is not everything, speed and memory consumption are very important characteristics for C++ developers, so having proper comparisons would be interesting.

1
.github/FUNDING.yml vendored
View File

@@ -1 +1,2 @@
github: nlohmann
custom: http://paypal.me/nlohmann

View File

@@ -7,16 +7,51 @@ assignees: ''
---
- What is the issue you have?
<!-- Provide a concise summary of the issue in the title above. -->
- Please describe the steps to reproduce the issue. Can you provide a small but working code example?
#### What is the issue you have?
- What is the expected behavior?
<!-- Provide a detailed introduction to the issue itself, and why you consider it to be a bug. -->
<!-- If possible, be specific and add stack traces, error messages, etc. Avoid vague terms like "crash" or "doesn't work". -->
- And what is the actual behavior instead?
#### Please describe the steps to reproduce the issue.
- Which compiler and operating system are you using? Is it a [supported compiler](https://github.com/nlohmann/json#supported-compilers)?
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
<!-- reproduce this bug. Include code to reproduce, if relevant -->
- Did you use a released version of the library or the version from the `develop` branch?
1.
2.
3.
- If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?
#### Can you provide a small but working code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### What is the expected behavior?
<!-- Tell us what should happen -->
#### And what is the actual behavior instead?
<!-- Tell us what happens instead. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
- Compiler: ___
- Operating system: ___
#### Which version of the library did you use?
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.7.3
- [ ] other release - please state the version: ___
- [ ] the `develop` branch
#### If you experience a compilation error: can you [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests)?
- [ ] yes
- [ ] no - please copy/paste the error message below

View File

@@ -7,6 +7,10 @@ assignees: ''
---
- Describe the feature in as much detail as possible.
#### Which feature do you want to see in the library?
- Include sample usage where appropriate.
<!-- Describe the feature in as much detail as possible. -->
#### How would the feature be usable for other users?
<!-- Include sample usage where appropriate. -->

View File

@@ -7,10 +7,34 @@ assignees: ''
---
- Describe what you want to achieve.
<!-- Provide a concise summary of the issue in the title above. -->
- Describe what you tried.
#### What do you want to achieve?
- Describe which system (OS, compiler) you are using.
<!-- Please describe the feature as detailed as possible. -->
- Describe which version of the library you are using (release version, develop branch).
#### What have you tried?
<!-- There are thousands of issues to search: https://github.com/nlohmann/json/issues?q=is%3Aissue+ -->
<!-- There is a full documentation of the API: https://nlohmann.github.io/json/ -->
<!-- There is a detailed README file: https://github.com/nlohmann/json/blob/develop/README.md -->
#### Can you provide a small code example?
<!-- Please understand that we cannot analyze and debug large code bases. -->
#### Which compiler and operating system are you using?
<!-- Include as many relevant details about the environment you experienced the bug in. -->
<!-- Make sure you use a supported compiler, see https://github.com/nlohmann/json#supported-compilers. -->
- Compiler: ___
- Operating system: ___
#### Which version of the library did you use?
<!-- Please add an `x` to the respective line. -->
- [ ] latest release version 3.7.3
- [ ] other release - please state the version: ___
- [ ] the `develop` branch

View File

@@ -15,5 +15,5 @@ Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop
- The C++11 support varies between different **compilers** and versions. Please note the [list of supported compilers](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers). Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with `#ifdef`s or other means.
- Specifically, I am aware of compilation problems with **Microsoft Visual Studio** (there even is an [issue label](https://github.com/nlohmann/json/issues?utf8=✓&q=label%3A%22visual+studio%22+) for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
- Please refrain from proposing changes that would **break [JSON](http://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please refrain from proposing changes that would **break [JSON](https://json.org) conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
- Please do not open pull requests that address **multiple issues**.

5
.github/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,5 @@
# Security Policy
## Reporting a Vulnerability
Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann/json/issues). If you want to make a private report (e.g., for a vulnerability or to attach an example that is not meant to be published), please send an email to <mail@nlohmann.me>. You can use [this key](https://keybase.io/nlohmann/pgp_keys.asc?fingerprint=797167ae41c0a6d9232e48457f3cea63ae251b69) for encryption.

17
.github/workflows/macos.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: macOS
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 --output-on-failure

17
.github/workflows/ubuntu.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Ubuntu
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 --output-on-failure

17
.github/workflows/windows.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Windows
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: cmake
run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
- name: build
run: cmake --build build --parallel 10
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure

9
.gitignore vendored
View File

@@ -18,8 +18,17 @@ me.nlohmann.json.docset
benchmarks/files/numbers/*.json
.wsjcpp-logs/*
.wsjcpp/*
.idea
cmake-build-debug
test/test-*
/.vs
doc/mkdocs/venv/
doc/mkdocs/docs/images
doc/mkdocs/docs/examples
doc/mkdocs/site
doc/mkdocs/docs/__pycache__/

View File

@@ -43,12 +43,15 @@ matrix:
- os: linux
compiler: clang
env:
- COMPILER=clang++-5.0
- COMPILER=clang++-7
- CMAKE_OPTIONS=-DJSON_Sanitizer=ON
- UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
packages: ['g++-6', 'clang-7', 'ninja-build']
before_script:
- export PATH=$PATH:/usr/lib/llvm-7/bin
# cppcheck
- os: linux
@@ -92,16 +95,17 @@ matrix:
- os: linux
compiler: gcc
dist: bionic
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ninja-build']
packages: ['g++-7', 'ninja-build']
before_script:
- pip install --user cpp-coveralls
after_success:
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp'
- coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp'
env:
- COMPILER=g++-4.9
- COMPILER=g++-7
- CMAKE_OPTIONS=-DJSON_Coverage=ON
- MULTIPLE_HEADERS=ON
@@ -128,18 +132,6 @@ matrix:
# OSX / Clang
- os: osx
osx_image: xcode8.3
- os: osx
osx_image: xcode9
- os: osx
osx_image: xcode9.1
- os: osx
osx_image: xcode9.2
- os: osx
osx_image: xcode9.3
@@ -152,11 +144,17 @@ matrix:
- os: osx
osx_image: xcode10.1
- os: osx
osx_image: xcode10.2
- os: osx
osx_image: xcode11.2
# Linux / GCC
- os: linux
compiler: gcc
env: compiler=g++-4.8
env: COMPILER=g++-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
@@ -164,7 +162,7 @@ matrix:
- os: linux
compiler: gcc
env: compiler=g++-4.9
env: COMPILER=g++-4.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
@@ -204,13 +202,21 @@ matrix:
- os: linux
compiler: gcc
env:
- COMPILER=g++-8
- CXXFLAGS=-std=c++17
env: COMPILER=g++-9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8', 'ninja-build']
packages: ['g++-9', 'ninja-build']
- os: linux
compiler: gcc
env:
- COMPILER=g++-9
- CXXFLAGS=-std=c++2a
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9', 'ninja-build']
# Linux / Clang
@@ -315,14 +321,10 @@ script:
# by default, use the single-header version
- if [[ "${MULTIPLE_HEADERS}" == "" ]]; then export MULTIPLE_HEADERS=OFF; fi
# show OS/compiler version
- uname -a
- $CXX --version
# compile and execute unit tests
- mkdir -p build && cd build
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release
- ctest -C Release -V -j
- cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release
- ctest -C Release --timeout 2700 -V -j
- cd ..
# check if homebrew works (only checks develop branch)

View File

@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1)
## PROJECT
## name and version
##
project(nlohmann_json VERSION 3.6.1 LANGUAGES CXX)
project(nlohmann_json VERSION 3.8.0 LANGUAGES CXX)
##
## INCLUDE
@@ -22,10 +22,11 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
##
## CONFIGURATION
##
include(GNUInstallDirs)
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}"
CACHE INTERNAL "")
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
@@ -47,7 +48,7 @@ endif()
##
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME})
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_range_for)
else()
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
@@ -88,8 +89,13 @@ endif()
## install header files, generate and install cmake config files for find_package()
##
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE} COMPATIBILITY SameMajorVersion
# use a custom package version config file instead of
# write_basic_package_version_file to ensure that it's architecture-independent
# https://github.com/nlohmann/json/issues/1697
configure_file(
"cmake/nlohmann_jsonConfigVersion.cmake.in"
${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
@ONLY
)
configure_file(
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
@@ -111,7 +117,7 @@ if(JSON_Install)
FILES ${NLOHMANN_NATVIS_FILE}
DESTINATION .
)
endif()
endif()
export(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
NAMESPACE ${PROJECT_NAME}::

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2013-2019 Niels Lohmann
Copyright (c) 2013-2020 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

751
Makefile
View File

@@ -1,51 +1,37 @@
.PHONY: pretty clean ChangeLog.md
.PHONY: pretty clean ChangeLog.md release
SRCS = include/nlohmann/json.hpp \
include/nlohmann/json_fwd.hpp \
include/nlohmann/adl_serializer.hpp \
include/nlohmann/detail/conversions/from_json.hpp \
include/nlohmann/detail/conversions/to_chars.hpp \
include/nlohmann/detail/conversions/to_json.hpp \
include/nlohmann/detail/exceptions.hpp \
include/nlohmann/detail/input/binary_reader.hpp \
include/nlohmann/detail/input/input_adapters.hpp \
include/nlohmann/detail/input/json_sax.hpp \
include/nlohmann/detail/input/lexer.hpp \
include/nlohmann/detail/input/parser.hpp \
include/nlohmann/detail/input/position_t.hpp \
include/nlohmann/detail/iterators/internal_iterator.hpp \
include/nlohmann/detail/iterators/iter_impl.hpp \
include/nlohmann/detail/iterators/iteration_proxy.hpp \
include/nlohmann/detail/iterators/json_reverse_iterator.hpp \
include/nlohmann/detail/iterators/primitive_iterator.hpp \
include/nlohmann/detail/json_pointer.hpp \
include/nlohmann/detail/json_ref.hpp \
include/nlohmann/detail/macro_scope.hpp \
include/nlohmann/detail/macro_unscope.hpp \
include/nlohmann/detail/meta/cpp_future.hpp \
include/nlohmann/detail/meta/detected.hpp \
include/nlohmann/detail/meta/type_traits.hpp \
include/nlohmann/detail/meta/void_t.hpp \
include/nlohmann/detail/output/binary_writer.hpp \
include/nlohmann/detail/output/output_adapters.hpp \
include/nlohmann/detail/output/serializer.hpp \
include/nlohmann/detail/value_t.hpp
UNAME = $(shell uname)
CXX=clang++
AMALGAMATED_FILE=single_include/nlohmann/json.hpp
##########################################################################
# configuration
##########################################################################
# directory to recent compiler binaries
COMPILER_DIR=/Users/niels/Documents/projects/compilers/local/bin
# find GNU sed to use `-i` parameter
SED:=$(shell command -v gsed || which sed)
##########################################################################
# source files
##########################################################################
# the list of sources in the include folder
SRCS=$(shell find include -type f | sort)
# the single header (amalgamated from the source files)
AMALGAMATED_FILE=single_include/nlohmann/json.hpp
##########################################################################
# documentation of the Makefile's targets
##########################################################################
# main target
all:
@echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources"
@echo "ChangeLog.md - generate ChangeLog file"
@echo "check - compile and execute test suite"
@echo "check-amalgamation - check whether sources have been amalgamated"
@echo "check-fast - compile and execute test suite (skip long-running tests)"
@echo "clean - remove built files"
@echo "coverage - create coverage information with lcov"
@echo "cppcheck - analyze code with cppcheck"
@@ -64,6 +50,7 @@ all:
@echo "pretty - beautify code with Artistic Style"
@echo "run_benchmarks - build and run benchmarks"
##########################################################################
# unit tests
##########################################################################
@@ -76,31 +63,20 @@ json_unit:
check:
$(MAKE) check -C test
check-fast:
$(MAKE) check -C test TEST_PATTERN=""
# clean up
clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM
rm -fr benchmarks/files/numbers/*.json
rm -fr build_coverage build_benchmarks
$(MAKE) clean -Cdoc
$(MAKE) clean -Ctest
##########################################################################
# coverage
##########################################################################
coverage:
rm -fr build_coverage
mkdir build_coverage
cd build_coverage ; CXX=g++-7 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd build_coverage ; cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd build_coverage ; ninja
cd build_coverage ; ctest -E '.*_default' -j10
cd build_coverage ; ctest -j10
cd build_coverage ; ninja lcov_html
open build_coverage/test/html/index.html
##########################################################################
# documentation tests
##########################################################################
@@ -115,266 +91,306 @@ doctest:
##########################################################################
# calling Clang with all warnings, except:
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
# -Wno-exit-time-destructors: warning in Catch code
# -Wno-keyword-macro: unit-tests use "#define private public"
# -Wno-deprecated-declarations: the library deprecated some functions
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-c++2a-compat: u8 literals will behave differently in C++20...
# -Wno-deprecated-declarations: the library deprecated some functions
# -Wno-documentation-unknown-command: code uses user-defined commands like @complexity
# -Wno-exit-time-destructors: warning in json code triggered by NLOHMANN_JSON_SERIALIZE_ENUM
# -Wno-float-equal: not all comparisons in the tests can be replaced by Approx
# -Wno-keyword-macro: unit-tests use "#define private public"
# -Wno-padded: padding is nothing to warn about
# -Wno-range-loop-analysis: items tests "for(const auto i...)"
# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches
# -Wno-weak-vtables: exception class is defined inline, but has virtual method
pedantic_clang:
$(MAKE) json_unit CXX=$(COMPILER_DIR)/clang++ CXXFLAGS=" \
rm -fr build_pedantic
CXXFLAGS=" \
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Werror \
-Weverything \
-Wno-c++2a-compat \
-Wno-deprecated-declarations \
-Wno-documentation-unknown-command \
-Wno-exit-time-destructors \
-Wno-keyword-macro \
-Wno-deprecated-declarations \
-Wno-weak-vtables \
-Wno-range-loop-analysis \
-Wno-float-equal \
-Wno-keyword-macro \
-Wno-padded \
-Wno-range-loop-analysis \
-Wno-switch-enum -Wno-covered-switch-default \
-Wno-c++2a-compat \
-Wno-c++17-extensions \
-Wno-padded"
-Wno-weak-vtables" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic
# calling GCC with most warnings
pedantic_gcc:
$(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS=" \
rm -fr build_pedantic
CXXFLAGS=" \
-std=c++11 \
-Waddress \
-Waddress-of-packed-member \
-Waggressive-loop-optimizations \
-Waligned-new=all \
-Wall \
-Walloc-zero \
-Walloca \
-Warray-bounds \
-Warray-bounds=2 \
-Wattribute-alias=2 \
-Wattribute-warning \
-Wattributes \
-Wbool-compare \
-Wbool-operation \
-Wbuiltin-declaration-mismatch \
-Wbuiltin-macro-redefined \
-Wcannot-profile \
-Wcast-align \
-Wcast-function-type \
-Wcast-qual \
-Wcatch-value=3 \
-Wchar-subscripts \
-Wclass-conversion \
-Wclass-memaccess \
-Wclobbered \
-Wcomment \
-Wcomments \
-Wconditionally-supported \
-Wconversion \
-Wconversion-null \
-Wcoverage-mismatch \
-Wcpp \
-Wctor-dtor-privacy \
-Wdangling-else \
-Wdate-time \
-Wdelete-incomplete \
-Wdelete-non-virtual-dtor \
-Wdeprecated \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
-Wdeprecated-declarations \
-Wdisabled-optimization \
-Wdiv-by-zero \
-Wdouble-promotion \
-Wduplicated-branches \
-Wduplicated-cond \
-Weffc++ \
-Wempty-body \
-Wendif-labels \
-Wenum-compare \
-Wexpansion-to-defined \
-pedantic \
-Werror \
-Wextra \
-Wextra-semi \
-Wfloat-conversion \
-Wfloat-equal \
-Wformat \
-Wformat-contains-nul \
-Wformat-extra-args \
-Wformat-nonliteral \
-Wformat-overflow=2 \
-Wformat-security \
-Wformat-signedness \
-Wformat-truncation=2 \
-Wformat-y2k \
-Wformat-zero-length \
-Wformat=2 \
-Wframe-address \
-Wfree-nonheap-object \
-Whsa \
-Wif-not-aligned \
-Wignored-attributes \
-Wignored-qualifiers \
-Wimplicit-fallthrough=5 \
-Winherited-variadic-ctor \
-Winit-list-lifetime \
-Winit-self \
-Winline \
-Wint-in-bool-context \
-Wint-to-pointer-cast \
-Winvalid-memory-model \
-Winvalid-offsetof \
-Winvalid-pch \
-Wliteral-suffix \
-Wlogical-not-parentheses \
-Wlogical-op \
-Wlto-type-mismatch \
-Wmain \
-Wmaybe-uninitialized \
-Wmemset-elt-size \
-Wmemset-transposed-args \
-Wmisleading-indentation \
-Wmissing-attributes \
-Wmissing-braces \
-Wmissing-declarations \
-Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wmissing-include-dirs \
-Wmissing-noreturn \
-Wmissing-profile \
-Wmultichar \
-Wmultiple-inheritance \
-Wmultistatement-macros \
-Wnarrowing \
-Wno-deprecated-declarations \
-Wno-long-long \
-Wno-namespaces \
-Wno-padded \
-Wno-switch-enum \
-Wno-system-headers \
-Wno-templates \
-Wno-undef \
-Wnoexcept \
-Wnoexcept-type \
-Wnon-template-friend \
-Wnon-virtual-dtor \
-Wnonnull \
-Wnonnull-compare \
-Wnonportable-cfstrings \
-Wnormalized \
-Wnull-dereference \
-Wodr \
-Wold-style-cast \
-Wopenmp-simd \
-Woverflow \
-Woverlength-strings \
-Woverloaded-virtual \
-Wpacked \
-Wpacked-bitfield-compat \
-Wpacked-not-aligned \
-Wparentheses \
-Wpedantic \
-Wpessimizing-move \
-Wplacement-new=2 \
-Wpmf-conversions \
-Wpointer-arith \
-Wpointer-compare \
-Wpragmas \
-Wprio-ctor-dtor \
-Wpsabi \
-Wredundant-decls \
-Wredundant-move \
-Wregister \
-Wreorder \
-Wrestrict \
-Wreturn-local-addr \
-Wreturn-type \
-Wscalar-storage-order \
-Wsequence-point \
-Wshadow \
-Wshadow-compatible-local \
-Wshadow-local \
-Wshadow=compatible-local \
-Wshadow=global \
-Wshadow=local \
-Wshift-count-negative \
-Wshift-count-overflow \
-Wshift-negative-value \
-Wshift-overflow=2 \
-Wsign-compare \
-Wsign-conversion \
-Wsign-promo \
-Wsized-deallocation \
-Wsizeof-array-argument \
-Wsizeof-pointer-div \
-Wsizeof-pointer-memaccess \
-Wstack-protector \
-Wstrict-aliasing=3 \
-Wstrict-null-sentinel \
-Wstrict-overflow=5 \
-Wstringop-overflow=4 \
-Wstringop-truncation \
-Wsubobject-linkage \
-Wsuggest-attribute=cold \
-Wsuggest-attribute=const \
-Wsuggest-attribute=format \
-Wsuggest-attribute=malloc \
-Wsuggest-attribute=noreturn \
-Wsuggest-attribute=pure \
-Wsuggest-final-methods \
-Wsuggest-final-types \
-Wsuggest-override \
-Wswitch \
-Wswitch-bool \
-Wswitch-default \
-Wswitch-unreachable \
-Wsync-nand \
-Wsynth \
-Wtautological-compare \
-Wterminate \
-Wtrampolines \
-Wtrigraphs \
-Wtype-limits \
-Wuninitialized \
-Wunknown-pragmas \
-Wunreachable-code \
-Wunsafe-loop-optimizations \
-Wunused \
-Wunused-but-set-parameter \
-Wunused-but-set-variable \
-Wunused-const-variable=2 \
-Wunused-function \
-Wunused-label \
-Wunused-local-typedefs \
-Wunused-macros \
-Wunused-parameter \
-Wunused-result \
-Wunused-value \
-Wunused-variable \
-Wuseless-cast \
-Wvarargs \
-Wvariadic-macros \
-Wvector-operation-performance \
-Wvirtual-inheritance \
-Wvirtual-move-assign \
-Wvla \
-Wvolatile-register-var \
-Wwrite-strings \
-Wzero-as-null-pointer-constant \
"
--all-warnings \
--extra-warnings \
-W \
-Wno-abi-tag \
-Waddress \
-Waddress-of-packed-member \
-Wno-aggregate-return \
-Waggressive-loop-optimizations \
-Waligned-new=all \
-Wall \
-Walloc-zero \
-Walloca \
-Wanalyzer-double-fclose \
-Wanalyzer-double-free \
-Wanalyzer-exposure-through-output-file \
-Wanalyzer-file-leak \
-Wanalyzer-free-of-non-heap \
-Wanalyzer-malloc-leak \
-Wanalyzer-null-argument \
-Wanalyzer-null-dereference \
-Wanalyzer-possible-null-argument \
-Wanalyzer-possible-null-dereference \
-Wanalyzer-stale-setjmp-buffer \
-Wanalyzer-tainted-array-index \
-Wanalyzer-too-complex \
-Wanalyzer-unsafe-call-within-signal-handler \
-Wanalyzer-use-after-free \
-Wanalyzer-use-of-pointer-in-stale-stack-frame \
-Warith-conversion \
-Warray-bounds \
-Warray-bounds=2 \
-Wattribute-alias=2 \
-Wattribute-warning \
-Wattributes \
-Wbool-compare \
-Wbool-operation \
-Wbuiltin-declaration-mismatch \
-Wbuiltin-macro-redefined \
-Wc++0x-compat \
-Wc++11-compat \
-Wc++14-compat \
-Wc++17-compat \
-Wc++1z-compat \
-Wc++20-compat \
-Wc++2a-compat \
-Wcannot-profile \
-Wcast-align \
-Wcast-align=strict \
-Wcast-function-type \
-Wcast-qual \
-Wcatch-value=3 \
-Wchar-subscripts \
-Wclass-conversion \
-Wclass-memaccess \
-Wclobbered \
-Wcomma-subscript \
-Wcomment \
-Wcomments \
-Wconditionally-supported \
-Wconversion \
-Wconversion-null \
-Wcoverage-mismatch \
-Wcpp \
-Wctor-dtor-privacy \
-Wdangling-else \
-Wdate-time \
-Wdelete-incomplete \
-Wdelete-non-virtual-dtor \
-Wdeprecated \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
-Wdeprecated-declarations \
-Wdisabled-optimization \
-Wdiv-by-zero \
-Wdouble-promotion \
-Wduplicated-branches \
-Wduplicated-cond \
-Weffc++ \
-Wempty-body \
-Wendif-labels \
-Wenum-compare \
-Wexpansion-to-defined \
-Wextra \
-Wextra-semi \
-Wfloat-conversion \
-Wfloat-equal \
-Wformat -Wformat-contains-nul \
-Wformat -Wformat-extra-args \
-Wformat -Wformat-nonliteral \
-Wformat -Wformat-security \
-Wformat -Wformat-y2k \
-Wformat -Wformat-zero-length \
-Wformat-diag \
-Wformat-overflow=2 \
-Wformat-signedness \
-Wformat-truncation=2 \
-Wformat=2 \
-Wframe-address \
-Wfree-nonheap-object \
-Whsa \
-Wif-not-aligned \
-Wignored-attributes \
-Wignored-qualifiers \
-Wimplicit-fallthrough=5 \
-Winaccessible-base \
-Winherited-variadic-ctor \
-Winit-list-lifetime \
-Winit-self \
-Winline \
-Wint-in-bool-context \
-Wint-to-pointer-cast \
-Winvalid-memory-model \
-Winvalid-offsetof \
-Winvalid-pch \
-Wliteral-suffix \
-Wlogical-not-parentheses \
-Wlogical-op \
-Wno-long-long \
-Wlto-type-mismatch \
-Wmain \
-Wmaybe-uninitialized \
-Wmemset-elt-size \
-Wmemset-transposed-args \
-Wmisleading-indentation \
-Wmismatched-tags \
-Wmissing-attributes \
-Wmissing-braces \
-Wmissing-declarations \
-Wmissing-field-initializers \
-Wmissing-include-dirs \
-Wmissing-profile \
-Wmultichar \
-Wmultiple-inheritance \
-Wmultistatement-macros \
-Wno-namespaces \
-Wnarrowing \
-Wno-noexcept \
-Wnoexcept-type \
-Wnon-template-friend \
-Wnon-virtual-dtor \
-Wnonnull \
-Wnonnull-compare \
-Wnonportable-cfstrings \
-Wnormalized=nfkc \
-Wnull-dereference \
-Wodr \
-Wold-style-cast \
-Wopenmp-simd \
-Woverflow \
-Woverlength-strings \
-Woverloaded-virtual \
-Wpacked \
-Wpacked-bitfield-compat \
-Wpacked-not-aligned \
-Wno-padded \
-Wparentheses \
-Wpedantic \
-Wpessimizing-move \
-Wplacement-new=2 \
-Wpmf-conversions \
-Wpointer-arith \
-Wpointer-compare \
-Wpragmas \
-Wprio-ctor-dtor \
-Wpsabi \
-Wredundant-decls \
-Wredundant-move \
-Wredundant-tags \
-Wregister \
-Wreorder \
-Wrestrict \
-Wreturn-local-addr \
-Wreturn-type \
-Wscalar-storage-order \
-Wsequence-point \
-Wshadow=compatible-local \
-Wshadow=global \
-Wshadow=local \
-Wshift-count-negative \
-Wshift-count-overflow \
-Wshift-negative-value \
-Wshift-overflow=2 \
-Wsign-compare \
-Wsign-conversion \
-Wsign-promo \
-Wsized-deallocation \
-Wsizeof-array-argument \
-Wsizeof-pointer-div \
-Wsizeof-pointer-memaccess \
-Wstack-protector \
-Wstrict-aliasing \
-Wstrict-aliasing=3 \
-Wstrict-null-sentinel \
-Wstrict-overflow \
-Wstrict-overflow=5 \
-Wstring-compare \
-Wstringop-overflow \
-Wstringop-overflow=4 \
-Wstringop-truncation \
-Wsubobject-linkage \
-Wsuggest-attribute=cold \
-Wsuggest-attribute=const \
-Wsuggest-attribute=format \
-Wsuggest-attribute=malloc \
-Wsuggest-attribute=noreturn \
-Wsuggest-attribute=pure \
-Wsuggest-final-methods \
-Wsuggest-final-types \
-Wsuggest-override \
-Wswitch \
-Wswitch-bool \
-Wswitch-default \
-Wno-switch-enum \
-Wswitch-outside-range \
-Wswitch-unreachable \
-Wsync-nand \
-Wsynth \
-Wno-system-headers \
-Wtautological-compare \
-Wno-templates \
-Wterminate \
-Wtrampolines \
-Wtrigraphs \
-Wtype-limits \
-Wundef \
-Wuninitialized \
-Wunknown-pragmas \
-Wunreachable-code \
-Wunsafe-loop-optimizations \
-Wunused \
-Wunused-but-set-parameter \
-Wunused-but-set-variable \
-Wunused-const-variable=2 \
-Wunused-function \
-Wunused-label \
-Wno-unused-local-typedefs \
-Wunused-macros \
-Wunused-parameter \
-Wunused-result \
-Wunused-value \
-Wunused-variable \
-Wuseless-cast \
-Wvarargs \
-Wvariadic-macros \
-Wvector-operation-performance \
-Wvirtual-inheritance \
-Wvirtual-move-assign \
-Wvla \
-Wvolatile \
-Wvolatile-register-var \
-Wwrite-strings \
-Wzero-as-null-pointer-constant \
-Wzero-length-bounds \
" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic
##########################################################################
# benchmarks
##########################################################################
run_benchmarks:
rm -fr build_benchmarks
mkdir build_benchmarks
cd build_benchmarks ; cmake ../benchmarks
cd build_benchmarks ; make
cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
cd build_benchmarks ; ninja
cd build_benchmarks ; ./json_benchmarks
##########################################################################
@@ -436,28 +452,39 @@ fuzzing-stop:
-killall fuzzer
-killall afl-fuzz
##########################################################################
# static analyzer
# Static analysis
##########################################################################
# call cppcheck on the main header file
# call cppcheck <http://cppcheck.sourceforge.net>
# Note: this target is called by Travis
cppcheck:
cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(SRCS) --error-exitcode=1
cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1
# compile and check with Clang Static Analyzer
# call Clang Static Analyzer <https://clang-analyzer.llvm.org>
clang_analyze:
rm -fr clang_analyze_build
mkdir clang_analyze_build
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja
cd clang_analyze_build ; $(COMPILER_DIR)/scan-build -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull --use-c++=$(COMPILER_DIR)/clang++ --view -analyze-headers -o clang_analyze_build/report.html ninja
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
cd clang_analyze_build ; \
$(COMPILER_DIR)/scan-build \
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
--use-c++=$(COMPILER_DIR)/clang++ -analyze-headers -o report ninja
open clang_analyze_build/report/*/index.html
# call cpplint (some errors expected due to false positives)
# call cpplint <https://github.com/cpplint/cpplint>
# Note: some errors expected due to false positives
cpplint:
third_party/cpplint/cpplint.py --filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit --quiet --recursive include
third_party/cpplint/cpplint.py \
--filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit \
--quiet --recursive $(SRCS)
# call Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>
clang_tidy:
$(COMPILER_DIR)/clang-tidy $(SRCS) -- -Iinclude -std=c++11
$(COMPILER_DIR)/clang-tidy $(AMALGAMATED_FILE) -- -Iinclude -std=c++11
# call PVS-Studio Analyzer <https://www.viva64.com/en/pvs-studio/>
pvs_studio:
rm -fr pvs_studio_build
mkdir pvs_studio_build
@@ -466,45 +493,70 @@ pvs_studio:
cd pvs_studio_build ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
open pvs_studio_build/pvs/index.html
# call Infer <https://fbinfer.com> static analyzer
infer:
rm -fr infer_build
mkdir infer_build
cd infer_build ; infer compile -- cmake .. ; infer run -- make -j 4
# call OCLint <http://oclint.org> static analyzer
oclint:
oclint $(SRCS) -report-type html -enable-global-analysis -o oclint_report.html -max-priority-1=10000 -max-priority-2=10000 -max-priority-3=10000 -- -std=c++11 -Iinclude
open oclint_report.html
# execute the test suite with Clang sanitizers (address and undefined behavior)
clang_sanitize:
rm -fr clang_sanitize_build
mkdir clang_sanitize_build
cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
cd clang_sanitize_build ; ninja
cd clang_sanitize_build ; ctest -j10
##########################################################################
# maintainer targets
# Code format and source amalgamation
##########################################################################
# pretty printer
# call the Artistic Style pretty printer on all source files
pretty:
astyle --style=allman --indent=spaces=4 --indent-modifiers \
--indent-switches --indent-preproc-block --indent-preproc-define \
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
--align-reference=type --add-brackets --convert-tabs --close-templates \
--lineend=linux --preserve-date --suffix=none --formatted \
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp \
benchmarks/src/benchmarks.cpp doc/examples/*.cpp
astyle \
--style=allman \
--indent=spaces=4 \
--indent-modifiers \
--indent-switches \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-header \
--align-pointer=type \
--align-reference=type \
--add-brackets \
--convert-tabs \
--close-templates \
--lineend=linux \
--preserve-date \
--suffix=none \
--formatted \
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp
# create single header file
amalgamate: $(AMALGAMATED_FILE)
# call the amalgamation tool and pretty print
$(AMALGAMATED_FILE): $(SRCS)
third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes
$(MAKE) pretty
# check if single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources
# check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources
# Note: this target is called by Travis
check-amalgamation:
@mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~
@$(MAKE) amalgamate
@diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false)
@mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE)
# check if every header in nlohmann includes sufficient headers to be compiled
# individually
# check if every header in nlohmann includes sufficient headers to be compiled individually
check-single-includes:
@for x in $(SRCS); do \
echo "Checking self-sufficiency of $$x..." ; \
@@ -513,29 +565,90 @@ check-single-includes:
rm -f single_include_test.cpp single_include_test; \
done
##########################################################################
# changelog
# CMake
##########################################################################
# grep "^option" CMakeLists.txt test/CMakeLists.txt | sed 's/(/ /' | awk '{print $2}' | xargs
# check if all flags of our CMake files work
check_cmake_flags_do:
$(CMAKE_BINARY) --version
for flag in '' JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \
rm -fr cmake_build; \
mkdir cmake_build; \
echo "$(CMAKE_BINARY) .. -D$$flag=On" ; \
cd cmake_build ; \
CXX=g++-8 $(CMAKE_BINARY) .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \
test -f Makefile || exit 1 ; \
cd .. ; \
done;
# call target `check_cmake_flags_do` twice: once for minimal required CMake version 3.1.0 and once for the installed version
check_cmake_flags:
wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Darwin64.tar.gz
tar xfz cmake-3.1.0-Darwin64.tar.gz
CMAKE_BINARY=$(abspath cmake-3.1.0-Darwin64/CMake.app/Contents/bin/cmake) $(MAKE) check_cmake_flags_do
CMAKE_BINARY=$(shell which cmake) $(MAKE) check_cmake_flags_do
##########################################################################
# ChangeLog
##########################################################################
# Create a ChangeLog based on the git log using the GitHub Changelog Generator
# (<https://github.com/github-changelog-generator/github-changelog-generator>).
# variable to control the diffs between the last released version and the current repository state
NEXT_VERSION ?= "unreleased"
ChangeLog.md:
github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md
github_changelog_generator -o ChangeLog.md --user nlohmann --project json --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION)
$(SED) -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md
$(SED) -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md
##########################################################################
# release
# Release files
##########################################################################
# Create the files for a release and add signatures and hashes. We use `-X` to make the resulting ZIP file
# reproducible, see <https://content.pivotal.io/blog/barriers-to-deterministic-reproducible-zip-files>.
release:
rm -fr release_files
mkdir release_files
zip -9 -r include.zip include/*
zip -9 --recurse-paths -X include.zip $(SRCS) $(AMALGAMATED_FILE) meson.build
gpg --armor --detach-sig include.zip
mv include.zip include.zip.asc release_files
gpg --armor --detach-sig single_include/nlohmann/json.hpp
cp single_include/nlohmann/json.hpp release_files
mv single_include/nlohmann/json.hpp.asc release_files
gpg --armor --detach-sig $(AMALGAMATED_FILE)
cp $(AMALGAMATED_FILE) release_files
mv $(AMALGAMATED_FILE).asc release_files
cd release_files ; shasum -a 256 json.hpp > hashes.txt
cd release_files ; shasum -a 256 include.zip >> hashes.txt
##########################################################################
# Maintenance
##########################################################################
# clean up
clean:
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html
rm -fr benchmarks/files/numbers/*.json
rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64
rm -fr build_coverage build_benchmarks fuzz-testing clang_analyze_build pvs_studio_build infer_build clang_sanitize_build cmake_build
$(MAKE) clean -Cdoc
$(MAKE) clean -Ctest
##########################################################################
# Thirdparty code
##########################################################################
update_hedley:
rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp
curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp
gsed -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp
grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp
$(MAKE) amalgamate

395
README.md
View File

@@ -2,19 +2,28 @@
[![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json)
[![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json)
[![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json)
[![Ubuntu](https://github.com/nlohmann/json/workflows/Ubuntu/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AUbuntu)
[![macOS](https://github.com/nlohmann/json/workflows/macOS/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AmacOS)
[![Windows](https://github.com/nlohmann/json/workflows/Windows/badge.svg)](https://github.com/nlohmann/json/actions?query=workflow%3AWindows)
[![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json)
[![Coverage Status](https://coveralls.io/repos/github/nlohmann/json/badge.svg?branch=develop)](https://coveralls.io/github/nlohmann/json?branch=develop)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nlohmann/json&amp;utm_campaign=Badge_Grade)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/nlohmann/json.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/nlohmann/json/context:cpp)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/TarF5pPn9NtHQjhf)
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](http://nlohmann.github.io/json)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/json.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:json)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
[![Documentation](https://img.shields.io/badge/docs-doxygen-blue.svg)](https://nlohmann.github.io/json/doxygen/index.html)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fnlohmann%2Fjson.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fnlohmann%2Fjson?ref=badge_shield)
[![GitHub Releases](https://img.shields.io/github/release/nlohmann/json.svg)](https://github.com/nlohmann/json/releases)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](http://github.com/nlohmann/json/issues)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/nlohmann/json.svg)](http://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue")
[![GitHub Downloads](https://img.shields.io/github/downloads/nlohmann/json/total)](https://github.com/nlohmann/json/releases)
[![GitHub Issues](https://img.shields.io/github/issues/nlohmann/json.svg)](https://github.com/nlohmann/json/issues)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/nlohmann/json.svg)](https://isitmaintained.com/project/nlohmann/json "Average time to resolve an issue")
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/289/badge)](https://bestpractices.coreinfrastructure.org/projects/289)
[![GitHub Sponsors](https://img.shields.io/badge/GitHub-Sponsors-ff69b4)](https://github.com/sponsors/nlohmann)
- [Design goals](#design-goals)
- [Sponsors](#sponsors)
- [Integration](#integration)
- [CMake](#cmake)
- [Package Managers](#package-managers)
@@ -40,13 +49,13 @@
## Design goals
There are myriads of [JSON](http://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
There are myriads of [JSON](https://json.org) libraries out there, and each may even have its reason to exist. Our class had these design goals:
- **Intuitive syntax**. In languages such as Python, JSON feels like a first class data type. We used all the operator magic of modern C++ to achieve the same feeling in your code. Check out the [examples below](#examples) and you'll know what I mean.
- **Trivial integration**. Our whole code consists of a single header file [`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp). That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings.
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/tree/develop/test/src) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](https://valgrind.org) and the [Clang Sanitizers](https://clang.llvm.org/docs/index.html) that there are no memory leaks. [Google OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/json) additionally runs fuzz tests against all parsers 24/7, effectively executing billions of tests so far. To maintain high quality, the project is following the [Core Infrastructure Initiative (CII) best practices](https://bestpractices.coreinfrastructure.org/projects/289).
Other aspects were not so important to us:
@@ -57,6 +66,19 @@ Other aspects were not so important to us:
See the [contribution guidelines](https://github.com/nlohmann/json/blob/master/.github/CONTRIBUTING.md#please-dont) for more information.
## Sponsors
You can sponsor this library at [GitHub Sponsors](https://github.com/sponsors/nlohmann).
### :label: Named Sponsors
- [Michael Hartmann](https://github.com/reFX-Mike)
- [Stefan Hagen](https://github.com/sthagen)
- [Steve Sperandeo](https://github.com/homer6)
Thanks everyone!
## Integration
[`json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is the single required file in `single_include/nlohmann` or [released here](https://github.com/nlohmann/json/releases). You need to add
@@ -115,6 +137,34 @@ add_library(foo ...)
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
```
##### Embedded (FetchContent)
Since CMake v3.11,
[FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html) can
be used to automatically download the repository as a dependency at configure type.
Example:
```cmake
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.7.3)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
target_link_libraries(foo PRIVATE nlohmann_json::nlohmann_json)
```
**Note**: The repository https://github.com/nlohmann/json download size is huge.
It contains all the dataset used for the benchmarks. You might want to depend on
a smaller repository. For instance, you might want to replace the URL above by
https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
#### Supporting Both
To allow your project to support either an externally supplied or an embedded JSON library, you can use a pattern akin to the following:
@@ -149,21 +199,23 @@ endif()
### Package Managers
:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann_json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann_json --HEAD`.
:beer: If you are using OS X and [Homebrew](https://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`.
If you are using the [Meson Build System](http://mesonbuild.com), then you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`.
If you are using the [Meson Build System](https://mesonbuild.com), add this source tree as a [meson subproject](https://mesonbuild.com/Subprojects.html#using-a-subproject). You may also use the `include.zip` published in this project's [Releases](https://github.com/nlohmann/json/releases) to reduce the size of the vendored source tree. Alternatively, you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. Please see the meson project for any issues regarding the packaging.
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `jsonformoderncpp/x.y.z@vthiery/stable` to your `conanfile.py`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/vthiery/conan-jsonformoderncpp/issues) if you experience problems with the packages.
The provided meson.build can also be used as an alternative to cmake for installing `nlohmann_json` system-wide in which case a pkg-config file is installed. To use it, simply have your build system require the `nlohmann_json` pkg-config dependency. In Meson, it is preferred to use the [`dependency()`](https://mesonbuild.com/Reference-manual.html#dependency) object with a subproject fallback, rather than using the subproject directly.
If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the `nlohmann_json` package. Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging.
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `nlohmann_json/x.y.z` to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages.
If you are using [hunter](https://github.com/ruslo/hunter/) on your project for external dependencies, then you can use the [nlohmann_json package](https://docs.hunter.sh/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging.
If you are using [Spack](https://www.spack.io/) to manage your dependencies, you can use the [`nlohmann-json` package](https://spack.readthedocs.io/en/latest/package_list.html#nlohmann-json). Please see the [spack project](https://github.com/spack/spack) for any issues regarding the packaging.
If you are using [hunter](https://github.com/cpp-pm/hunter) on your project for external dependencies, then you can use the [nlohmann_json package](https://hunter.readthedocs.io/en/latest/packages/pkg/nlohmann_json.html). Please see the hunter project for any issues regarding the packaging.
If you are using [Buckaroo](https://buckaroo.pm), you can install this library's module with `buckaroo add github.com/buckaroo-pm/nlohmann-json`. Please file issues [here](https://github.com/buckaroo-pm/nlohmann-json). There is a demo repo [here](https://github.com/njlr/buckaroo-nholmann-json-example).
If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [nlohmann-json package](https://github.com/Microsoft/vcpkg/tree/master/ports/nlohmann-json). Please see the vcpkg project for any issues regarding the packaging.
If you are using [cget](http://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`).
If you are using [cget](https://cget.readthedocs.io/en/latest/), you can install the latest development version with `cget install nlohmann/json`. A specific version can be installed with `cget install nlohmann/json@v3.1.0`. Also, the multiple header version can be installed by adding the `-DJSON_MultipleHeaders=ON` flag (i.e., `cget install nlohmann/json -DJSON_MultipleHeaders=ON`).
If you are using [CocoaPods](https://cocoapods.org), you can use the library by adding pod `"nlohmann_json", '~>3.1.2'` to your podfile (see [an example](https://bitbucket.org/benman/nlohmann_json-cocoapod/src/master/)). Please file issues [here](https://bitbucket.org/benman/nlohmann_json-cocoapod/issues?status=new&status=open).
@@ -171,6 +223,13 @@ If you are using [NuGet](https://www.nuget.org), you can use the package [nlohma
If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues).
If you are using [MSYS2](https://www.msys2.org/), your can use the [mingw-w64-nlohmann-json](https://packages.msys2.org/base/mingw-w64-nlohmann-json) package, just type `pacman -S mingw-w64-i686-nlohmann-json` or `pacman -S mingw-w64-x86_64-nlohmann-json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann-json%5D) if you experience problems with the packages.
If you are using [`build2`](https://build2.org), you can use the [`nlohmann-json`](https://cppget.org/nlohmann-json) package from the public repository https://cppget.org or directly from the [package's sources repository](https://github.com/build2-packaging/nlohmann-json). In your project's `manifest` file, just add `depends: nlohmann-json` (probably with some [version constraints](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml#guide-add-remove-deps)). If you are not familiar with using dependencies in `build2`, [please read this introduction](https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml).
Please file issues [here](https://github.com/build2-packaging/nlohmann-json) if you experience problems with the packages.
If you are using [`wsjcpp`](https://wsjcpp.org), you can use the command `wsjcpp install "https://github.com/nlohmann/json:develop"` to get the latest version. Note you can change the branch ":develop" to an existing tag or another branch.
## Examples
Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5338e282d1d02bed389d852dd670d98d.html#a5338e282d1d02bed389d852dd670d98d)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)).
@@ -242,7 +301,7 @@ json j2 = {
};
```
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa80485befaffcadaa39965494e0b4d2e.html#aa80485befaffcadaa39965494e0b4d2e) and [`json::object`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa13f7c0615867542ce80337cbcf13ada.html#aa13f7c0615867542ce80337cbcf13ada) will help:
Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a9ad7ec0bc1082ed09d10900fbb20a21f.html#a9ad7ec0bc1082ed09d10900fbb20a21f) and [`json::object()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aaf509a7c029100d292187068f61c99b8.html#aaf509a7c029100d292187068f61c99b8) will help:
```cpp
// a way to express the empty array []
@@ -277,7 +336,7 @@ auto j2 = R"(
Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object.
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5a0339361f3282cb8fd2f9ede6e17d72.html#a5a0339361f3282cb8fd2f9ede6e17d72):
The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a265a473e939184aa42655c9ccdf34e58.html#a265a473e939184aa42655c9ccdf34e58):
```cpp
// parse explicitly
@@ -288,7 +347,7 @@ You can also get a string representation of a JSON value (serialize):
```cpp
// explicit conversion to string
std::string s = j.dump(); // {\"happy\":true,\"pi\":3.141}
std::string s = j.dump(); // {"happy":true,"pi":3.141}
// serialization with pretty printing
// pass in the amount of spaces to indent
@@ -320,7 +379,7 @@ std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get<std::
std::cout << j_string << " == " << serialized_string << std::endl;
```
[`.dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) always returns the serialized value, and [`.get<std::string>()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a16f9445f7629f634221a42b967cdcd43.html#a16f9445f7629f634221a42b967cdcd43) returns the originally stored string value.
[`.dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) always returns the serialized value, and [`.get<std::string>()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa6602bb24022183ab989439e19345d08.html#aa6602bb24022183ab989439e19345d08) returns the originally stored string value.
Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
@@ -357,7 +416,7 @@ Please note that setting the exception bit for `failbit` is inappropriate for th
#### Read from iterator range
You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose content is stored as contiguous byte sequence, for instance a `std::vector<std::uint8_t>`:
You can also parse JSON from an iterator range; that is, from any container accessible by iterators whose `value_type` is an integral type of 1, 2 or 4 bytes, which will be interpreted as UTF-8, UTF-16 and UTF-32 respectively. For instance, a `std::vector<std::uint8_t>`, or a `std::list<std::uint16_t>`:
```cpp
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
@@ -371,6 +430,53 @@ std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
json j = json::parse(v);
```
#### Custom data source
Since the parse function accepts arbitrary iterator ranges, you can provide your own data sources by implementing the `LegacyInputIterator` concept.
```cpp
struct MyContainer {
void advance();
const char& get_current();
};
struct MyIterator {
using difference_type = std::ptrdiff_t;
using value_type = char;
using pointer = const char*;
using reference = const char&;
using iterator_category = std::input_iterator_tag;
MyIterator& operator++() {
MyContainer.advance();
return *this;
}
bool operator!=(const MyIterator& rhs) const {
return rhs.target != target;
}
reference operator*() const {
return target.get_current();
}
MyContainer* target = nullptr;
};
MyIterator begin(MyContainer& tgt) {
return MyIterator{&tgt};
}
MyIterator end(const MyContainer&) {
return {};
}
void foo() {
MyContainer c;
json j = json::parse(c);
}
```
#### SAX interface
The library uses a SAX-like interface with the following functions:
@@ -444,7 +550,7 @@ j[1] = 42;
bool foo = j.at(2);
// comparison
j == "[\"foo\", 1, true]"_json; // true
j == "[\"foo\", 42, true]"_json; // true
// other stuff
j.size(); // 3 entries
@@ -485,6 +591,11 @@ for (auto& [key, value] : o.items()) {
}
// find an entry
if (o.contains("foo")) {
// there is an entry with key "foo"
}
// or via find and an iterator
if (o.find("foo") != o.end()) {
// there is an entry with key "foo"
}
@@ -924,7 +1035,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM( TaskState, {
})
```
The `NLOHMANN_JSON_SERIALIZE_ENUM()` macro declares a set of `to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serilization code.
The `NLOHMANN_JSON_SERIALIZE_ENUM()` macro declares a set of `to_json()` / `from_json()` functions for type `TaskState` while avoiding repetition and boilerplate serialization code.
**Usage:**
@@ -952,7 +1063,7 @@ Other Important points:
### Binary formats (BSON, CBOR, MessagePack, and UBJSON)
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](http://bsonspec.org) (Binary JSON), [CBOR](http://cbor.io) (Concise Binary Object Representation), [MessagePack](http://msgpack.org), and [UBJSON](http://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors.
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports [BSON](http://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), and [UBJSON](http://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors.
```cpp
// create a JSON value
@@ -991,16 +1102,47 @@ std::vector<std::uint8_t> v_ubjson = json::to_ubjson(j);
json j_from_ubjson = json::from_ubjson(v_ubjson);
```
The library also supports binary types from BSON, CBOR (byte strings), and MessagePack (bin, ext, fixext). They are stored by default as `std::vector<std::uint8_t>` to be processed outside of the library.
```cpp
// CBOR byte string with payload 0xCAFE
std::vector<std::uint8_t> v = {0x42, 0xCA, 0xFE};
// read value
json j = json::from_cbor(v);
// the JSON value has type binary
j.is_binary(); // true
// get reference to stored binary value
auto& binary = j.get_binary();
// the binary value has no subtype (CBOR has no binary subtypes)
binary.has_subtype(); // false
// access std::vector<std::uint8_t> member functions
binary.size(); // 2
binary[0]; // 0xCA
binary[1]; // 0xFE
// set subtype to 0x10
binary.set_subtype(0x10);
// serialize to MessagePack
auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE
```
## Supported compilers
Though it's 2019 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
Though it's 2020 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:
- GCC 4.8 - 9.0 (and possibly later)
- Clang 3.4 - 8.0 (and possibly later)
- GCC 4.8 - 10.1 (and possibly later)
- Clang 3.4 - 10.0 (and possibly later)
- Intel C++ Compiler 17.0.2 (and possibly later)
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
- Microsoft Visual C++ 2017 / Build Tools 15.5.180.51428 (and possibly later)
- Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later)
I would be happy to learn about other compilers/versions.
@@ -1017,39 +1159,46 @@ Please note:
The code compiles successfully with [Android NDK](https://developer.android.com/ndk/index.html?hl=ml), Revision 9 - 11 (and possibly later) and [CrystaX's Android NDK](https://www.crystax.net/en/android/ndk) version 10.
- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](http://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
- For GCC running on MinGW or Android SDK, the error `'to_string' is not a member of 'std'` (or similarly, for `strtod` or `strtof`) may occur. Note this is not an issue with the code, but rather with the compiler itself. On Android, see above to build with a newer environment. For MinGW, please refer to [this site](https://tehsausage.com/mingw-to-string) and [this discussion](https://github.com/nlohmann/json/issues/136) for information on how to fix this bug. For Android NDK using `APP_STL := gnustl_static`, please refer to [this discussion](https://github.com/nlohmann/json/issues/219).
- Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case.
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json) and [AppVeyor](https://ci.appveyor.com/project/nlohmann/json):
The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [GitHub Actions](https://github.com/nlohmann/json/actions), and [CircleCI](https://circleci.com/gh/nlohmann/json):
| Compiler | Operating System | Version String |
|-----------------|------------------------------|----------------|
| GCC 4.8.5 | Ubuntu 14.04.5 LTS | g++-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.2) 4.8.5 |
| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 |
| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 |
| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 |
| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 |
| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 |
| GCC 8.1.0 | Ubuntu 14.04.1 LTS | g++-8 (Ubuntu 8.1.0-5ubuntu1~14.04) 8.1.0 |
| Clang 3.5.0 | Ubuntu 14.04.1 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) |
| Clang 3.6.2 | Ubuntu 14.04.1 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) |
| Clang 3.7.1 | Ubuntu 14.04.1 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) |
| Clang 3.8.0 | Ubuntu 14.04.1 LTS | clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) |
| Clang 3.9.1 | Ubuntu 14.04.1 LTS | clang version 3.9.1-4ubuntu3~14.04.3 (tags/RELEASE_391/rc2) |
| Clang 4.0.1 | Ubuntu 14.04.1 LTS | clang version 4.0.1-svn305264-1~exp1 (branches/release_40) |
| Clang 5.0.2 | Ubuntu 14.04.1 LTS | clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50) |
| Clang 6.0.1 | Ubuntu 14.04.1 LTS | clang version 6.0.1-svn334776-1~exp1~20180726133705.85 (branches/release_60) |
| Clang 7.0.1 | Ubuntu 14.04.1 LTS | clang version 7.0.1-svn348686-1~exp1~20181213084532.54 (branches/release_70) |
| Clang Xcode 8.3 | OSX 10.11.6 | Apple LLVM version 8.1.0 (clang-802.0.38) |
| Clang Xcode 9.0 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.37) |
| Clang Xcode 9.1 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.38) |
| Clang Xcode 9.2 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.1) |
| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) |
| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) |
| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) |
| Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25420.1, MSVC 19.0.24215.1 |
| Visual Studio 2017 | Windows Server 2016 | Microsoft (R) Build Engine version 15.7.180.61344, MSVC 19.14.26433.0 |
| Compiler | Operating System | CI Provider |
|-----------------------------------------------------------------|--------------------|----------------|
| Apple Clang 9.1.0 (clang-902.0.39.1); Xcode 9.3 | macOS 10.13.3 | Travis |
| Apple Clang 9.1.0 (clang-902.0.39.2); Xcode 9.4.1 | macOS 10.13.6 | Travis |
| Apple Clang 10.0.0 (clang-1000.11.45.2); Xcode 10.0 | macOS 10.13.6 | Travis |
| Apple Clang 10.0.0 (clang-1000.11.45.5); Xcode 10.1 | macOS 10.13.6 | Travis |
| Apple Clang 10.0.1 (clang-1001.0.46.4); Xcode 10.2.1 | macOS 10.14.4 | Travis |
| Apple Clang 11.0.0 (clang-1100.0.33.12); Xcode 11.2.1 | macOS 10.14.6 | Travis |
| Apple Clang 11.0.3 (clang-1103.0.32.59); Xcode 11.4.1 | macOS 10.15.4 | GitHub Actions |
| Clang 3.5.0 (3.5.0-4ubuntu2~trusty2) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.6.2 (3.6.2-svn240577-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.7.1 (3.7.1-svn253571-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.8.0 (3.8.0-2ubuntu3~trusty5) | Ubuntu 14.04.5 LTS | Travis |
| Clang 3.9.1 (3.9.1-4ubuntu3~14.04.3) | Ubuntu 14.04.5 LTS | Travis |
| Clang 4.0.1 (4.0.1-svn305264-1~exp1) | Ubuntu 14.04.5 LTS | Travis |
| Clang 5.0.2 (version 5.0.2-svn328729-1~exp1~20180509123505.100) | Ubuntu 14.04.5 LTS | Travis |
| Clang 6.0.1 (6.0.1-svn334776-1~exp1~20190309042707.121) | Ubuntu 14.04.5 LTS | Travis |
| Clang 7.1.0 (7.1.0-svn353565-1~exp1~20190419134007.64) | Ubuntu 14.04.5 LTS | Travis |
| Clang 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | Travis |
| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu8~14.04.2) | Ubuntu 14.04.5 LTS | Travis |
| GCC 4.9.4 (Ubuntu 4.9.4-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| GCC 5.5.0 (Ubuntu 5.5.0-12ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis |
| GCC 6.3.0 (Debian 6.3.0-18+deb9u1) | Debian 9 | Circle CI |
| GCC 6.5.0 (Ubuntu 6.5.0-2ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| GCC 7.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-6.3.9600 | AppVeyor |
| GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1~14.04.1) | Ubuntu 14.04.5 LTS | Travis |
| GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | GitHub Actions |
| GCC 8.4.0 (Ubuntu 8.4.0-1ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis |
| GCC 9.3.0 (Ubuntu 9.3.0-11ubuntu0~14.04) | Ubuntu 14.04.5 LTS | Travis |
| GCC 10.1.0 (Arch Linux latest) | Arch Linux | Circle CI |
| MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor |
| MSVC 19.16.27035.0 (15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor |
| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | AppVeyor |
| MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | GitHub Actions |
## License
@@ -1067,13 +1216,15 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
* * *
The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2008-2009 [Björn Hoehrmann](http://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de>
The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2008-2009 [Björn Hoehrmann](https://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de>
The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2009 [Florian Loitsch](http://florian.loitsch.com/)
The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright &copy; 2009 [Florian Loitsch](https://florian.loitsch.com/)
The class contains a copy of [Hedley](https://nemequ.github.io/hedley/) from Evan Nemerson which is licensed as [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/).
## Contact
If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases.
If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new/choose). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases.
Only if your request would contain confidential information, please [send me an email](mailto:mail@nlohmann.me). For encrypted messages, please use [this key](https://keybase.io/nlohmann/pgp_keys.asc).
@@ -1126,7 +1277,7 @@ I deeply appreciate the help of the following people.
- [Mário Feroldi](https://github.com/thelostt) fixed a small typo.
- [duncanwerner](https://github.com/duncanwerner) found a really embarrassing performance regression in the 2.0.0 release.
- [Damien](https://github.com/dtoma) fixed one of the last conversion warnings.
- [Thomas Braun](https://github.com/t-b) fixed a warning in a test case.
- [Thomas Braun](https://github.com/t-b) fixed a warning in a test case and adjusted MSVC calls in the CI.
- [Théo DELRIEU](https://github.com/theodelrieu) patiently and constructively oversaw the long way toward [iterator-range parsing](https://github.com/nlohmann/json/issues/290). He also implemented the magic behind the serialization/deserialization of user-defined types and split the single header file into smaller chunks.
- [Stefan](https://github.com/5tefan) fixed a minor issue in the documentation.
- [Vasil Dimov](https://github.com/vasild) fixed the documentation regarding conversions from `std::multiset`.
@@ -1242,7 +1393,7 @@ I deeply appreciate the help of the following people.
- [Ivor Wanders](https://github.com/iwanders) helped reducing the CMake requirement to version 3.1.
- [njlr](https://github.com/njlr) updated the Buckaroo instructions.
- [Lion](https://github.com/lieff) fixed a compilation issue with GCC 7 on CentOS.
- [Isaac Nickaein](https://github.com/nickaein) improved the integer serilization performance and implemented the `contains()` function.
- [Isaac Nickaein](https://github.com/nickaein) improved the integer serialization performance and implemented the `contains()` function.
- [past-due](https://github.com/past-due) suppressed an unfixable warning.
- [Elvis Oric](https://github.com/elvisoric) improved Meson support.
- [Matěj Plch](https://github.com/Afforix) fixed an example in the README.
@@ -1254,6 +1405,53 @@ I deeply appreciate the help of the following people.
- [Hani](https://github.com/hnkb) documented how to install the library with NuGet.
- [Mark Beckwith](https://github.com/wythe) fixed a typo.
- [yann-morin-1998](https://github.com/yann-morin-1998) helped reducing the CMake requirement to version 3.1.
- [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro.
- [remyabel](https://github.com/remyabel) added GNUInstallDirs to the CMake files.
- [Taylor Howard](https://github.com/taylorhoward92) fixed a unit test.
- [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method.
- [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning.
- [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest)
- [Juncheng E](https://github.com/ejcjason) fixed a typo.
- [tete17](https://github.com/tete17) fixed a bug in the `contains` function.
- [Xav83](https://github.com/Xav83) fixed some cppcheck warnings.
- [0xflotus](https://github.com/0xflotus) fixed some typos.
- [Christian Deneke](https://github.com/chris0x44) added a const version of `json_pointer::back`.
- [Julien Hamaide](https://github.com/crazyjul) made the `items()` function work with custom string types.
- [Evan Nemerson](https://github.com/nemequ) updated fixed a bug in Hedley and updated this library accordingly.
- [Florian Pigorsch](https://github.com/flopp) fixed a lot of typos.
- [Camille Bégué](https://github.com/cbegue) fixed an issue in the conversion from `std::pair` and `std::tuple` to `json`.
- [Anthony VH](https://github.com/AnthonyVH) fixed a compile error in an enum deserialization.
- [Yuriy Vountesmery](https://github.com/ua-code-dragon) noted a subtle bug in a preprocessor check.
- [Chen](https://github.com/dota17) fixed numerous issues in the library.
- [Antony Kellermann](https://github.com/aokellermann) added a CI step for GCC 10.1.
- [Alex](https://github.com/gistrec) fixed an MSVC warning.
- [Rainer](https://github.com/rvjr) proposed an improvement in the floating-point serialization in CBOR.
- [Francois Chabot](https://github.com/FrancoisChabot) made performance improvements in the input adapters.
- [Arthur Sonzogni](https://github.com/ArthurSonzogni) documented how the library can be included via `FetchContent`.
- [Rimas Misevičius](https://github.com/rmisev) fixed an error message.
- [Alexander Myasnikov](https://github.com/alexandermyasnikov) fixed some examples and a link in the README.
- [Hubert Chathi](https://github.com/uhoreg) made CMake's version config file architecture-independent.
- [OmnipotentEntity](https://github.com/OmnipotentEntity) implemented the binary values for CBOR, MessagePack, BSON, and UBJSON.
- [ArtemSarmini](https://github.com/ArtemSarmini) fixed a compilation issue with GCC 10 and fixed a leak.
- [Evgenii Sopov](https://github.com/sea-kg) integrated the library to the wsjcpp package manager.
- [Sergey Linev](https://github.com/linev) fixed a compiler warning.
- [Miguel Magalhães](https://github.com/magamig) fixed the year in the copyright.
- [Gareth Sylvester-Bradley](https://github.com/garethsb-sony) fixed a compilation issue with MSVC.
- [Alexander “weej” Jones](https://github.com/alex-weej) fixed an example in the README.
- [Antoine Cœur](https://github.com/Coeur) fixed some typos in the documentation.
- [jothepro](https://github.com/jothepro) updated links to the Hunter package.
- [Dave Lee](https://github.com/kastiglione) fixed link in the README.
- [Joël Lamotte](https://github.com/Klaim) added instruction for using Build2's package manager.
- [Paul Jurczak](https://github.com/pauljurczak) fixed an example in the README.
- [Sonu Lohani](https://github.com/sonulohani) fixed a warning.
- [Carlos Gomes Martinho](https://github.com/gocarlos) updated the Conan package source.
- [Konstantin Podsvirov](https://github.com/podsvirov) fixed the MSYS2 package documentation.
- [Tridacnid](https://github.com/Tridacnid) improved the CMake tests.
- [Michael](https://github.com/MBalszun) fixed MSVC warnings.
- [Quentin Barbarat](https://github.com/quentin-dev) fixed an example in the documentation.
- [XyFreak](https://github.com/XyFreak) fixed a compiler warning.
- [TotalCaesar659](https://github.com/TotalCaesar659) fixed links in the README.
- [Tanuj Garg](https://github.com/tanuj208) improved the fuzzer coverage for UBSAN input.
Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.
@@ -1263,27 +1461,30 @@ Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I
The library itself consists of a single header file licensed under the MIT license. However, it is built, tested, documented, and whatnot using a lot of third-party tools and services. Thanks a lot!
- [**amalgamate.py - Amalgamate C source and header files**](https://github.com/edlund/amalgamate) to create a single header file
- [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing
- [**American fuzzy lop**](https://lcamtuf.coredump.cx/afl/) for fuzz testing
- [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows
- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code identation
- [**Catch**](https://github.com/philsquared/Catch) for the unit tests
- [**Clang**](http://clang.llvm.org) for compilation with code sanitizers
- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation
- [**CircleCI**](https://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json).
- [**Clang**](https://clang.llvm.org) for compilation with code sanitizers
- [**CMake**](https://cmake.org) for build automation
- [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json)
- [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json)
- [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json)
- [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis
- [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/)
- [**doctest**](https://github.com/onqtam/doctest) for the unit tests
- [**Doxygen**](https://www.doxygen.nl/index.html) to generate [documentation](https://nlohmann.github.io/json/doxygen/index.html)
- [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages
- [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md)
- [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks
- [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz
- [**Hedley**](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros
- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view
- [**libFuzzer**](https://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz
- [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json))
- [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments.
- [**send_to_wandbox**](https://github.com/nlohmann/json/blob/develop/doc/scripts/send_to_wandbox.py) to send code examples to [Wandbox](http://melpon.org/wandbox)
- [**Travis**](https://travis-ci.org) for [continuous integration](https://travis-ci.org/nlohmann/json) on Linux and macOS
- [**Valgrind**](http://valgrind.org) to check for correct memory management
- [**Wandbox**](http://melpon.org/wandbox) for [online examples](https://wandbox.org/permlink/TarF5pPn9NtHQjhf)
- [**Valgrind**](https://valgrind.org) to check for correct memory management
- [**Wandbox**](https://wandbox.org) for [online examples](https://wandbox.org/permlink/3lCHrFUZANONKv7a)
## Projects using JSON for Modern C++
@@ -1293,18 +1494,56 @@ The library is currently used in Apple macOS Sierra and iOS 10. I am not sure wh
## Notes
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8).
- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc7159.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
- The library supports **Unicode input** as follows:
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](https://tools.ietf.org/html/rfc7159.html#section-8.1).
- Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse or serialization errors.
- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by an `abort()` call.
- By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)).
### Character encoding
The library supports **Unicode input** as follows:
- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1).
- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers.
- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors.
- [Unicode noncharacters](https://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library.
- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors.
- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs.
- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers.
### Comments in JSON
This library does not support comments. It does so for three reasons:
1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript.
2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012:
> I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.
> Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.
3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this.
This library will not support comments in the future. If you wish to use comments, I see three options:
1. Strip comments before using this library.
2. Use a different JSON library with comment support.
3. Use a format that natively supports comments (e.g., YAML or JSON5).
### Order of object keys
By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)).
### Memory Release
We checked with Valgrind and the Address Sanitizer (ASAN) that there are no memory leaks.
If you find that a parsing program with this library does not release memory, please consider the following case and it maybe unrelated to this library.
**Your program is compiled with glibc.** There is a tunable threshold that glibc uses to decide whether to actually return memory to the system or whether to cache it for later reuse. If in your program you make lots of small allocations and those small allocations are not a contiguous block and are presumably below the threshold, then they will not get returned to the OS.
Here is a related issue [#1924](https://github.com/nlohmann/json/issues/1924).
### Further notes
- The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8).
- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions.
- The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag.
- **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by `abort()` calls. You can further control this behavior by defining `JSON_THROW_USER´` (overriding `throw`), `JSON_TRY_USER` (overriding `try`), and `JSON_CATCH_USER` (overriding `catch`). Note that `JSON_THROW_USER` should leave the current scope (e.g., by throwing or aborting), as continuing after it may yield undefined behavior.
## Execute unit tests
@@ -1313,7 +1552,7 @@ To compile and run the tests, you need to execute
```sh
$ mkdir build
$ cd build
$ cmake ..
$ cmake .. -DJSON_BuildTests=On
$ cmake --build .
$ ctest --output-on-failure
```

View File

@@ -3,6 +3,35 @@ version: '{build}'
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Debug
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Debug
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Debug
COMPILER: mingw
platform: x86
CXX_FLAGS: ""
@@ -10,57 +39,88 @@ environment:
GENERATOR: Ninja
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
COMPILER: mingw
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Ninja
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x86
name: with_win_header
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 15 2017
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Release
platform: x86
CXX_FLAGS: "/permissive- /std:c++latest /utf-8"
LINKER_FLAGS: ""
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Release
platform: x86
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 14 2015 Win64
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 15 2017 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
platform: x64
CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000"
CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000"
LINKER_FLAGS: "/STACK:4000000"
GENERATOR: Visual Studio 15 2017 Win64
GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
configuration: Release
platform: x64
CXX_FLAGS: ""
LINKER_FLAGS: ""
GENERATOR: Visual Studio 16 2019
init:
- cmake --version
- msbuild /version
install:
- if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip
- if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul
- if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH%
- if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH%
- if "%COMPILER%"=="mingw" g++ --version
- if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip
- if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul
- if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH%
- if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH%
- if "%COMPILER%"=="mingw" g++ --version
- if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32
before_build:
- cmake . -G "%GENERATOR%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin"
# for with_win_header build, inject the inclusion of Windows.h to the single-header library
- ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" }
- ps: if ($env:name -Eq "with_win_header") { "#include <Windows.h>`n" + (Get-Content $header_path | Out-String) | Set-Content $header_path }
- if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On) else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On)
build_script:
- cmake --build . --config Release
- cmake --build . --config "%configuration%"
test_script:
- ctest -C Release -V -j
- if "%configuration%"=="Release" ctest -C "%configuration%" -V -j
# On Debug builds, skip test-unicode_all
# as it is extremely slow to run and cause
# occasional timeouts on AppVeyor.
# More info: https://github.com/nlohmann/json/pull/1570
- if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j

View File

@@ -14,15 +14,12 @@ add_subdirectory(thirdparty/benchmark)
include_directories(thirdparty)
include_directories(${CMAKE_SOURCE_DIR}/../single_include)
# copy test files to build folder
file(COPY ${CMAKE_SOURCE_DIR}/data DESTINATION .)
file(COPY ${CMAKE_SOURCE_DIR}/../test/data/regression/floats.json
${CMAKE_SOURCE_DIR}/../test/data/regression/unsigned_ints.json
${CMAKE_SOURCE_DIR}/../test/data/regression/signed_ints.json
${CMAKE_SOURCE_DIR}/../test/data/regression/small_signed_ints.json
DESTINATION data/numbers)
# download test data
include(${CMAKE_SOURCE_DIR}/../cmake/download_test_data.cmake)
# benchmark binary
add_executable(json_benchmarks src/benchmarks.cpp)
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
add_dependencies(json_benchmarks download_test_data)
target_include_directories(json_benchmarks PRIVATE ${CMAKE_BINARY_DIR}/include)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
#include "benchmark/benchmark.h"
#include <nlohmann/json.hpp>
#include <fstream>
#include <test_data.hpp>
using json = nlohmann::json;
@@ -28,14 +29,14 @@ static void ParseFile(benchmark::State& state, const char* filename)
std::ifstream file(filename, std::ios::binary | std::ios::ate);
state.SetBytesProcessed(state.iterations() * file.tellg());
}
BENCHMARK_CAPTURE(ParseFile, jeopardy, "data/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseFile, canada, "data/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseFile, citm_catalog, "data/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseFile, twitter, "data/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseFile, floats, "data/numbers/floats.json");
BENCHMARK_CAPTURE(ParseFile, signed_ints, "data/numbers/signed_ints.json");
BENCHMARK_CAPTURE(ParseFile, unsigned_ints, "data/numbers/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseFile, small_signed_ints, "data/numbers/small_signed_ints.json");
BENCHMARK_CAPTURE(ParseFile, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseFile, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseFile, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseFile, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseFile, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
BENCHMARK_CAPTURE(ParseFile, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
BENCHMARK_CAPTURE(ParseFile, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseFile, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
//////////////////////////////////////////////////////////////////////////////
// parse JSON from string
@@ -61,14 +62,14 @@ static void ParseString(benchmark::State& state, const char* filename)
state.SetBytesProcessed(state.iterations() * str.size());
}
BENCHMARK_CAPTURE(ParseString, jeopardy, "data/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseString, canada, "data/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseString, citm_catalog, "data/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseString, twitter, "data/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseString, floats, "data/numbers/floats.json");
BENCHMARK_CAPTURE(ParseString, signed_ints, "data/numbers/signed_ints.json");
BENCHMARK_CAPTURE(ParseString, unsigned_ints, "data/numbers/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseString, small_signed_ints, "data/numbers/small_signed_ints.json");
BENCHMARK_CAPTURE(ParseString, jeopardy, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json");
BENCHMARK_CAPTURE(ParseString, canada, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json");
BENCHMARK_CAPTURE(ParseString, citm_catalog, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json");
BENCHMARK_CAPTURE(ParseString, twitter, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json");
BENCHMARK_CAPTURE(ParseString, floats, TEST_DATA_DIRECTORY "/regression/floats.json");
BENCHMARK_CAPTURE(ParseString, signed_ints, TEST_DATA_DIRECTORY "/regression/signed_ints.json");
BENCHMARK_CAPTURE(ParseString, unsigned_ints, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json");
BENCHMARK_CAPTURE(ParseString, small_signed_ints, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json");
//////////////////////////////////////////////////////////////////////////////
@@ -88,22 +89,22 @@ static void Dump(benchmark::State& state, const char* filename, int indent)
state.SetBytesProcessed(state.iterations() * j.dump(indent).size());
}
BENCHMARK_CAPTURE(Dump, jeopardy / -, "data/jeopardy/jeopardy.json", -1);
BENCHMARK_CAPTURE(Dump, jeopardy / 4, "data/jeopardy/jeopardy.json", 4);
BENCHMARK_CAPTURE(Dump, canada / -, "data/nativejson-benchmark/canada.json", -1);
BENCHMARK_CAPTURE(Dump, canada / 4, "data/nativejson-benchmark/canada.json", 4);
BENCHMARK_CAPTURE(Dump, citm_catalog / -, "data/nativejson-benchmark/citm_catalog.json", -1);
BENCHMARK_CAPTURE(Dump, citm_catalog / 4, "data/nativejson-benchmark/citm_catalog.json", 4);
BENCHMARK_CAPTURE(Dump, twitter / -, "data/nativejson-benchmark/twitter.json", -1);
BENCHMARK_CAPTURE(Dump, twitter / 4, "data/nativejson-benchmark/twitter.json", 4);
BENCHMARK_CAPTURE(Dump, floats / -, "data/numbers/floats.json", -1);
BENCHMARK_CAPTURE(Dump, floats / 4, "data/numbers/floats.json", 4);
BENCHMARK_CAPTURE(Dump, signed_ints / -, "data/numbers/signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, signed_ints / 4, "data/numbers/signed_ints.json", 4);
BENCHMARK_CAPTURE(Dump, unsigned_ints / -, "data/numbers/unsigned_ints.json", -1);
BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, "data/numbers/unsigned_ints.json", 4);
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, "data/numbers/small_signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, "data/numbers/small_signed_ints.json", 4);
BENCHMARK_CAPTURE(Dump, jeopardy / -, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", -1);
BENCHMARK_CAPTURE(Dump, jeopardy / 4, TEST_DATA_DIRECTORY "/jeopardy/jeopardy.json", 4);
BENCHMARK_CAPTURE(Dump, canada / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", -1);
BENCHMARK_CAPTURE(Dump, canada / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/canada.json", 4);
BENCHMARK_CAPTURE(Dump, citm_catalog / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", -1);
BENCHMARK_CAPTURE(Dump, citm_catalog / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/citm_catalog.json", 4);
BENCHMARK_CAPTURE(Dump, twitter / -, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", -1);
BENCHMARK_CAPTURE(Dump, twitter / 4, TEST_DATA_DIRECTORY "/nativejson-benchmark/twitter.json", 4);
BENCHMARK_CAPTURE(Dump, floats / -, TEST_DATA_DIRECTORY "/regression/floats.json", -1);
BENCHMARK_CAPTURE(Dump, floats / 4, TEST_DATA_DIRECTORY "/regression/floats.json", 4);
BENCHMARK_CAPTURE(Dump, signed_ints / -, TEST_DATA_DIRECTORY "/regression/signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, signed_ints / 4, TEST_DATA_DIRECTORY "/regression/signed_ints.json", 4);
BENCHMARK_CAPTURE(Dump, unsigned_ints / -, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", -1);
BENCHMARK_CAPTURE(Dump, unsigned_ints / 4, TEST_DATA_DIRECTORY "/regression/unsigned_ints.json", 4);
BENCHMARK_CAPTURE(Dump, small_signed_ints / -, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", -1);
BENCHMARK_CAPTURE(Dump, small_signed_ints / 4, TEST_DATA_DIRECTORY "/regression/small_signed_ints.json", 4);
BENCHMARK_MAIN();

View File

@@ -0,0 +1,51 @@
find_package(Git)
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
set(JSON_TEST_DATA_VERSION 2.0.0)
# target to download test data
add_custom_target(download_test_data
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# create a header with the path to the downloaded test data
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
# determine the operating system (for debug and support purposes)
find_program(UNAME_COMMAND uname)
find_program(VER_COMMAND ver)
find_program(LSB_RELEASE_COMMAND lsb_release)
find_program(SW_VERS_COMMAND sw_vers)
set(OS_VERSION_STRINGS "${CMAKE_SYSTEM}")
if (VER_COMMAND)
execute_process(COMMAND ${VER_COMMAND} OUTPUT_VARIABLE VER_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${VER_COMMAND_RESULT}")
endif()
if (SW_VERS_COMMAND)
execute_process(COMMAND ${SW_VERS_COMMAND} OUTPUT_VARIABLE SW_VERS_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
string(REGEX REPLACE "[ ]*\n" "; " SW_VERS_COMMAND_RESULT "${SW_VERS_COMMAND_RESULT}")
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${SW_VERS_COMMAND_RESULT}")
endif()
if (LSB_RELEASE_COMMAND)
execute_process(COMMAND ${LSB_RELEASE_COMMAND} -a OUTPUT_VARIABLE LSB_RELEASE_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
string(REGEX REPLACE "[ ]*\n" "; " LSB_RELEASE_COMMAND_RESULT "${LSB_RELEASE_COMMAND_RESULT}")
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${LSB_RELEASE_COMMAND_RESULT}")
endif()
if (UNAME_COMMAND)
execute_process(COMMAND ${UNAME_COMMAND} -a OUTPUT_VARIABLE UNAME_COMMAND_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
set(OS_VERSION_STRINGS "${OS_VERSION_STRINGS}; ${UNAME_COMMAND_RESULT}")
endif()
message(STATUS "Operating system: ${OS_VERSION_STRINGS}")
# determine the compiler (for debug and support purposes)
if (MSVC)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE CXX_VERSION_RESULT ERROR_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_COMPILER "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
else()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")

View File

@@ -0,0 +1,20 @@
# This is essentially cmake's BasicConfigVersion-SameMajorVersion.cmake.in but
# without the 32/64-bit check. Since json is a header-only library, it doesn't
# matter if it was built on a different platform than what it is used on (see
# https://github.com/nlohmann/json/issues/1697).
set(PACKAGE_VERSION "@PROJECT_VERSION@")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
else()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
endif()
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@@ -1,11 +1,11 @@
# Doxyfile 1.8.16
# Doxyfile 1.8.19
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "JSON for Modern C++"
PROJECT_NUMBER = 3.6.1
PROJECT_NUMBER = 3.8.0
PROJECT_BRIEF =
PROJECT_LOGO =
OUTPUT_DIRECTORY = .
@@ -23,6 +23,7 @@ STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
JAVADOC_BANNER = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
@@ -33,7 +34,6 @@ ALIASES = "complexity=@par Complexity^^" \
"requirement=@par Requirements^^" \
"exceptionsafety=@par Exception safety^^" \
"iterators=@par Iterator validity^^"
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
@@ -59,6 +59,7 @@ LOOKUP_CACHE_SIZE = 0
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_PRIV_VIRTUAL = NO
EXTRACT_PACKAGE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
@@ -109,9 +110,7 @@ WARN_LOGFILE =
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../single_include/nlohmann/json.hpp \
index.md \
faq.md \
binary_formats.md
index.md
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = NO
@@ -140,9 +139,6 @@ REFERENCES_LINK_SOURCE = NO
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
CLANG_ASSISTED_PARSING = YES
CLANG_OPTIONS = -std=c++11
CLANG_DATABASE_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
@@ -194,8 +190,10 @@ GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
HTML_FORMULA_FORMAT = png
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
FORMULA_MACROFILE =
USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
@@ -293,12 +291,10 @@ GENERATE_TAGFILE = html/nlohmann_json.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
MSCGEN_PATH =
DIA_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES

View File

@@ -61,6 +61,8 @@ doxygen: create_output create_links
$(SED) -i 's@template&lt;template&lt; typename U, typename V, typename... Args &gt; class ObjectType = std::map, template&lt; typename U, typename... Args &gt; class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template&lt; typename U &gt; class AllocatorType = std::allocator, template&lt; typename T, typename SFINAE=void &gt; class JSONSerializer = adl_serializer&gt;@@g' html/*.html
$(SED) -i 's@&lt; ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer &gt;@@g' html/*.html
$(SED) -i 's@&lt;&#160;ObjectType,&#160;ArrayType,&#160;StringType,&#160;BooleanType,&#160;NumberIntegerType,&#160;NumberUnsignedType,&#160;NumberFloatType,&#160;AllocatorType,&#160;JSONSerializer&#160;&gt;@@g' html/*.html
$(SED) -i 's@JSON_HEDLEY_RETURNS_NON_NULL@@g' html/*.html
$(SED) -i 's@JSON_HEDLEY_WARN_UNUSED_RESULT@@g' html/*.html
upload: clean doxygen check_output
scripts/git-update-ghpages nlohmann/json html

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -1,171 +0,0 @@
# Binary formats
![conversion between JSON and binary formats](images/binary.png)
Several formats exist that encode JSON values in a binary format to reduce the size of the encoded value as well as the required effort to parse encoded value. The library implements three formats, namely
- [CBOR](https://tools.ietf.org/html/rfc7049) (Concise Binary Object Representation)
- [MessagePack](https://msgpack.org)
- [UBJSON](http://ubjson.org) (Universal Binary JSON)
## Interface
### JSON to binary format
For each format, the `to_*` functions (i.e., `to_cbor`, `to_msgpack`, and `to_ubjson`) convert a JSON value into the respective binary format. Taking CBOR as example, the concrete prototypes are:
```cpp
static std::vector<uint8_t> to_cbor(const basic_json& j); // 1
static void to_cbor(const basic_json& j, detail::output_adapter<uint8_t> o); // 2
static void to_cbor(const basic_json& j, detail::output_adapter<char> o); // 3
```
The first function creates a byte vector from the given JSON value. The second and third function writes to an output adapter of `uint8_t` and `char`, respectively. Output adapters are implemented for strings, output streams, and vectors.
Given a JSON value `j`, the following calls are possible:
```cpp
std::vector<uint8_t> v;
v = json::to_cbor(j); // 1
json::to_cbor(j, v); // 2
std::string s;
json::to_cbor(j, s); // 3
std::ostringstream oss;
json::to_cbor(j, oss); // 3
```
### Binary format to JSON
Likewise, the `from_*` functions (i.e, `from_cbor`, `from_msgpack`, and `from_ubjson`) convert a binary encoded value into a JSON value. Taking CBOR as example, the concrete prototypes are:
```cpp
static basic_json from_cbor(detail::input_adapter i, const bool strict = true); // 1
static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true); // 2
```
Both functions read from an input adapter: the first function takes it directly form argument `i`, whereas the second function creates it from the provided arguments `a1` and `a2`. If the optional parameter `strict` is true, the input must be read completely (or a parse error exception is thrown). If it is false, parsing succeeds even if the input is not completely read.
Input adapters are implemented for input streams, character buffers, string literals, and iterator ranges.
Given several inputs (which we assume to be filled with a CBOR value), the following calls are possible:
```cpp
std::string s;
json j1 = json::from_cbor(s); // 1
std::ifstream is("somefile.cbor", std::ios::binary);
json j2 = json::from_cbor(is); // 1
std::vector<uint8_t> v;
json j3 = json::from_cbor(v); // 1
const char* buff;
std::size_t buff_size;
json j4 = json::from_cbor(buff, buff_size); // 2
```
## Details
### CBOR
The mapping from CBOR to JSON is **incomplete** in the sense that not all CBOR types can be converted to a JSON value. The following CBOR types are not supported and will yield parse errors (parse_error.112):
- byte strings (0x40..0x5F)
- date/time (0xC0..0xC1)
- bignum (0xC2..0xC3)
- decimal fraction (0xC4)
- bigfloat (0xC5)
- tagged items (0xC6..0xD4, 0xD8..0xDB)
- expected conversions (0xD5..0xD7)
- simple values (0xE0..0xF3, 0xF8)
- undefined (0xF7)
CBOR further allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected (parse_error.113).
The mapping from JSON to CBOR is **complete** in the sense that any JSON value type can be converted to a CBOR value.
If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the dump() function which serializes NaN or Infinity to null.
The following CBOR types are not used in the conversion:
- byte strings (0x40..0x5F)
- UTF-8 strings terminated by "break" (0x7F)
- arrays terminated by "break" (0x9F)
- maps terminated by "break" (0xBF)
- date/time (0xC0..0xC1)
- bignum (0xC2..0xC3)
- decimal fraction (0xC4)
- bigfloat (0xC5)
- tagged items (0xC6..0xD4, 0xD8..0xDB)
- expected conversions (0xD5..0xD7)
- simple values (0xE0..0xF3, 0xF8)
- undefined (0xF7)
- half and single-precision floats (0xF9-0xFA)
- break (0xFF)
### MessagePack
The mapping from MessagePack to JSON is **incomplete** in the sense that not all MessagePack types can be converted to a JSON value. The following MessagePack types are not supported and will yield parse errors:
- bin 8 - bin 32 (0xC4..0xC6)
- ext 8 - ext 32 (0xC7..0xC9)
- fixext 1 - fixext 16 (0xD4..0xD8)
The mapping from JSON to MessagePack is **complete** in the sense that any JSON value type can be converted to a MessagePack value.
The following values can not be converted to a MessagePack value:
- strings with more than 4294967295 bytes
- arrays with more than 4294967295 elements
- objects with more than 4294967295 elements
The following MessagePack types are not used in the conversion:
- bin 8 - bin 32 (0xC4..0xC6)
- ext 8 - ext 32 (0xC7..0xC9)
- float 32 (0xCA)
- fixext 1 - fixext 16 (0xD4..0xD8)
Any MessagePack output created `to_msgpack` can be successfully parsed by `from_msgpack`.
If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the `dump()` function which serializes NaN or Infinity to `null`.
### UBJSON
The mapping from UBJSON to JSON is **complete** in the sense that any UBJSON value can be converted to a JSON value.
The mapping from JSON to UBJSON is **complete** in the sense that any JSON value type can be converted to a UBJSON value.
The following values can not be converted to a UBJSON value:
- strings with more than 9223372036854775807 bytes (theoretical)
- unsigned integer numbers above 9223372036854775807
The following markers are not used in the conversion:
- `Z`: no-op values are not created.
- `C`: single-byte strings are serialized with S markers.
Any UBJSON output created to_ubjson can be successfully parsed by from_ubjson.
If NaN or Infinity are stored inside a JSON number, they are serialized properly. This behavior differs from the `dump()` function which serializes NaN or Infinity to null.
The optimized formats for containers are supported: Parameter `use_size` adds size information to the beginning of a container and removes the closing marker. Parameter `use_type` further checks whether all elements of a container have the same type and adds the type marker to the beginning of the container. The `use_type` parameter must only be used together with `use_size = true`. Note that `use_size = true` alone may result in larger representations - the benefit of this parameter is that the receiving side is immediately informed on the number of elements of the container.
## Size comparison examples
The following table shows the size compared to the original JSON value for different files from the repository for the different formats.
| format | sample.json | all_unicode.json | floats.json | signed_ints.json | jeopardy.json | canada.json |
| ----------------------- | -----------:| ----------------:| -----------:| ----------------:| -------------:| -----------:|
| JSON | 100.00 % | 100.00 % | 100.00 % | 100.00 % | 100.00 % | 100.00 % |
| CBOR | 87.21 % | 71.18 % | 48.20 % | 44.16 % | 87.96 % | 50.53 % |
| MessagePack | 87.16 % | 71.18 % | 48.20 % | 44.16 % | 87.91 % | 50.56 % |
| UBJSON unoptimized | 88.15 % | 100.00 % | 48.20 % | 44.16 % | 96.58 % | 53.20 % |
| UBJSON size-optimized | 89.26 % | 100.00 % | 48.20 % | 44.16 % | 97.40 % | 58.56 % |
| UBJSON format-optimized | 89.45 % | 100.00 % | 42.85 % | 39.26 % | 94.96 % | 55.93 % |
The results show that there does not exist a "best" encoding. Furthermore, it is not always worthwhile to use UBJSON's optimizations.

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/uAyi8CvcGwzGQ406"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/EezQxM0Nzi8tTUEe"><b>online</b></a>

View File

@@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a valid JSON text
auto valid_text = R"(
{
"numbers": [1, 2, 3]
}
)";
// an invalid JSON text
auto invalid_text = R"(
{
"strings": ["extra", "comma", ]
}
)";
std::cout << std::boolalpha
<< json::accept(valid_text) << ' '
<< json::accept(invalid_text) << '\n';
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/r5Tai1spihWHTdFA"><b>online</b></a>

View File

@@ -0,0 +1 @@
true false

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/piWraYhVg2CV3j2H"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/Ptk2BoNyGfrZfxRU"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/wtWzPSQWWiuxldVs"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/055DW3OWJPwGYr92"><b>online</b></a>

View File

@@ -6,7 +6,7 @@ using json = nlohmann::json;
int main()
{
// create JSON object
json object =
const json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/Zh3iTnZNxsSgBvm3"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/gM1uqvzukokLwjMa"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/MfM8XIuPWMvxxdeb"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/H3tBOr4lpufGRHlF"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/eFEcnFZxfdLGSMhw"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/UtGhIQGxCYIml36F"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/ST2lraxpPLdDOUFn"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/NHe5FLR1KYaiHwBx"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/FkPwquIlr9pojvGf"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/lbZjdwg6yII33cV5"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/AxHC1Xl6KALWJ0FJ"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/swnzqmd8zj6ij1fb"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/pylFciQUhOx6zXW8"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/RodBcX8vpcP5dQ40"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/KCfRvbW3QTvghlFb"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/oWFo4AhVlMBjNv8E"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/TM0OkdSgEIGBDbrv"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/oRn0YsYyurs0Zi5T"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/jWDJPXw490IFoVL1"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/kVknQzPMpqjywTpG"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/FR2ImEj05R1bqqZ2"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/yzkjGGzMOESBkCdH"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/XTHN0lMT9QsmBcBy"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/eIOvQiuID2qgxp5u"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/iCwvXJinCVY7q1vi"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/Vm0nR32x6co8rq40"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/BzyeWqt4uTQ2nbfx"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/w4TtEQzlVyokIrtp"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/zFWa3Zyot2oM3Z8O"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/mNy1nyabOkeHfHGf"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/ECfvMr4m68Mfr192"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/a3H6kpORXgbVXylv"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/LNck7Gktm14bmPy0"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/yXZGDwDHH3LOuFIr"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to the first element
// get an iterator to the first element
json::iterator it = array.begin();
// serialize the element that the iterator points to

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/xKAi3HGAdCU5y2dS"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/fS4kfQG1hmhjMScn"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create an array value
const json array = {1, 2, 3, 4, 5};
// get am iterator to the first element
// get an iterator to the first element
json::const_iterator it = array.cbegin();
// serialize the element that the iterator points to

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/oKNo3GDUa9cxjgVB"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/hxcSxCPPLHpZMxjS"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to one past the last element
// get an iterator to one past the last element
json::const_iterator it = array.cend();
// decrement the iterator to point to the last element

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/mP4cOSG4MtXmXlFw"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/xbnldrrN05tKIOEv"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/0W6xYpQWS5Kd64CF"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/gDQPYFxMrvD7RK4z"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/iHSlXjtjhgO9Q1Tw"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/vVY4F4xKC3v6pG6F"><b>online</b></a>

View File

@@ -0,0 +1,42 @@
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
std::cout << std::boolalpha
<< j.contains("/number"_json_pointer) << '\n'
<< j.contains("/string"_json_pointer) << '\n'
<< j.contains("/array"_json_pointer) << '\n'
<< j.contains("/array/1"_json_pointer) << '\n'
<< j.contains("/array/-"_json_pointer) << '\n'
<< j.contains("/array/4"_json_pointer) << '\n'
<< j.contains("/baz"_json_pointer) << std::endl;
try
{
// try to use an array index with leading '0'
j.contains("/array/01"_json_pointer);
}
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
try
{
// try to use an array index that is not a number
j.contains("/array/one"_json_pointer);
}
catch (json::parse_error& e)
{
std::cout << e.what() << '\n';
}
}

View File

@@ -0,0 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/Q2GTzxF8NA10kVvD"><b>online</b></a>

View File

@@ -0,0 +1,7 @@
true
true
true
true
false
false
false

View File

@@ -8,7 +8,7 @@ int main()
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call find
// call count()
auto count_two = j_object.count("two");
auto count_three = j_object.count("three");

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/4qmbLSA75stzPgtZ"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/6LRjg1bqwchPUoDx"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/mcjh1kDXXkzq7TxM"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/JMDd9jiP0flRKJ6C"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/6tH3hnp53iVzAQZQ"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/HdlqwPk8bDfrZ4AE"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/3OPLSVPyweUyEHaX"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/GHVHgDpT5vx0KMPD"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/KtH6hJIe10abhHMi"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/DyMiKrkKMwd3R7OU"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/zIQBGY6fKqiMmbvb"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/p9P3Ph8mdxMON6SY"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/QEbpCnjGIpFWmYbE"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/yMxKrJfRedlFygJD"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/AcEmkGmmmz0dPdHW"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/zaexgkNdH3HYJm8D"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create an array value
json array = {1, 2, 3, 4, 5};
// get am iterator to one past the last element
// get an iterator to one past the last element
json::iterator it = array.end();
// decrement the iterator to point to the last element

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/rSTMI3VXUFtNCWNc"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/eQ0YI8wWcMIHtBCS"><b>online</b></a>

View File

@@ -13,7 +13,7 @@ int main()
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call erase
// call erase()
j_boolean.erase(j_boolean.begin());
j_number_integer.erase(j_number_integer.begin());
j_number_float.erase(j_number_float.begin());

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/nh51Nho7iuAAAPyk"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/SD62jUgeIuudweZu"><b>online</b></a>

View File

@@ -13,7 +13,7 @@ int main()
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call erase
// call erase()
j_boolean.erase(j_boolean.begin(), j_boolean.end());
j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
j_number_float.erase(j_number_float.begin(), j_number_float.end());

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/xqf45a27zQqgthtB"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/gG3bN97HOF04Xw6S"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call erase
// call erase()
auto count_one = j_object.erase("one");
auto count_three = j_object.erase("three");

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/lMcaGzTQuWn44ly1"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/WSnobkZJZHUPUIRF"><b>online</b></a>

View File

@@ -8,7 +8,7 @@ int main()
// create a JSON array
json j_array = {0, 1, 2, 3, 4, 5};
// call erase
// call erase()
j_array.erase(2);
// print values

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/7fA2QoclBNAGZprY"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/GGoqGtqEzxAsAKnI"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/9ESgIBWRarZRJvCw"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/vky6QCTCqtUnNVlD"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/AQubfCmv848Q66Zi"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/aQjZSjuuDUxXQCjJ"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/4bn447WQbTERfBaL"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/moO4IdryeGS8QmKo"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/qtfoxfHO7u4eKMcO"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/Q7O1liz5QrgQynqQ"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/AHKW5EMQN4YQ68TY"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/AjdbchxfTsN9PHCL"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/J0KoQF8sOpdMg4kN"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/TdJfkKx0RAH5NB62"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/uuQK0DAjhbSd96K6"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/GG9VzOZh1MDeTSsK"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/5NtCbAfPzCmmPd5S"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/LtqaiI6oRplSg0KI"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/frQdC0nigwUVSZ21"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/ddVSXnbULrNrCbRs"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/M4EHlf0MaujBQlub"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/QjVgxx0bwbKuE9HI"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/G1pg9ZBD5n15TZli"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/eA1KrytMlQl1SURe"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/eKlCbdm2UdqXs3hS"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/jVaWWe3kAjKKn99V"><b>online</b></a>

View File

@@ -1 +1 @@
<a target="_blank" href="https://wandbox.org/permlink/QxtxaO6JZAMJPutC"><b>online</b></a>
<a target="_blank" href="https://wandbox.org/permlink/UvdMlXdPnXFUq1lJ"><b>online</b></a>

Some files were not shown because too many files have changed in this diff Show More