1
0
mirror of https://github.com/nlohmann/json.git synced 2026-07-22 03:33:02 +04:00

Compare commits

..

2674 Commits

Author SHA1 Message Date
Niels Lohmann 8c20571136 Merge branch 'release/3.2.0' 2018-08-20 19:36:10 +02:00
Niels Lohmann 9f3857ef6f 🔖 set version to 3.2.0 2018-08-18 18:46:15 +02:00
Niels Lohmann 7608a64e1e 🔨 fixed amalgamation 2018-08-18 18:14:12 +02:00
Niels Lohmann a7b02bdce0 🔖 preparing 3.2.0 release 2018-08-18 17:48:49 +02:00
Niels Lohmann c6a482b16c 📝 added example for sax_parse 2018-08-18 15:42:18 +02:00
Niels Lohmann 5ad52f4167 ⬆️ Catch 1.12.0 2018-08-18 12:02:12 +02:00
Niels Lohmann 3811daa8a3 📝 release preparation 2018-08-18 12:00:14 +02:00
Niels Lohmann 6899fa304c Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-08-18 08:15:06 +02:00
Niels Lohmann 57faaf42ca 🚨 fixed a compiler warning 2018-08-18 08:15:03 +02:00
Niels Lohmann f78ac4fbd3 Merge pull request #1200 from thyu/develop
Fix -Wno-sometimes-uninitialized by initializing "result" in parse_sax
2018-08-18 08:14:04 +02:00
Tsz-Ho Yu 3004a73951 Fix -Wno-sometimes-uninitialized by initializing "result" in parse_sax
The function parse_sax() returns sometimes-uninitialized warnings in
some compilers. This commit fixes that.
2018-08-18 01:12:19 +01:00
Niels Lohmann e33b31e6aa 🐛 fixed callback-related issue (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) 2018-08-17 23:09:45 +02:00
Niels Lohmann b5c54b41fd 📝 overworked documentation 2018-08-16 21:53:47 +02:00
Niels Lohmann 07494e06d7 🚨 fixed some compiler warnings 2018-08-16 18:20:30 +02:00
Niels Lohmann d5b21b051c Merge pull request #1153 from theodelrieu/refactor/no_virtual_sax
Refactor/no virtual sax
2018-08-16 17:47:55 +02:00
Théo DELRIEU 0cc3db4f15 add static_asserts on SAX interface 2018-08-16 11:59:57 +02:00
Théo DELRIEU 38f8a51a8f use abstract sax class in parser tests 2018-08-16 11:59:49 +02:00
Théo DELRIEU 9bbb133094 remove no_limit constant and default values 2018-08-16 11:59:05 +02:00
Théo DELRIEU 442886d040 use templates in the sax interface instead of virtuals 2018-08-16 11:58:52 +02:00
Théo DELRIEU f6febbe359 split meta.hpp, add detected_t (used to define concepts) 2018-08-16 11:58:42 +02:00
Niels Lohmann 3ac2d81a95 🔨 fixed a MinGW error #1193 2018-08-14 22:13:56 +02:00
Niels Lohmann be2065dce9 🚨 fixing a MinGW warning #1192 2018-08-14 22:11:47 +02:00
Niels Lohmann fed70f6bff 🎨 reindented code 2018-08-14 22:11:08 +02:00
Niels Lohmann 0e748f2f8c Merge pull request #1187 from devsisters/json-internal-catch
[RFC] Introduce a new macro function: JSON_INTERNAL_CATCH
2018-08-14 21:56:29 +02:00
Niels Lohmann 861ee400cc Merge pull request #1176 from grembo/develop
Fix unit tests that were silently skipped or crashed (depending on the compiler)
2018-08-14 21:48:49 +02:00
Niels Lohmann 3ce4325350 📝 updated documentation of used compilers 2018-08-01 22:31:51 +02:00
Niels Lohmann ba4a19d4af 👷 added more CI workers 2018-08-01 20:59:58 +02:00
Niels Lohmann 043eff5ba8 👷 added more CI workers 2018-07-31 21:18:33 +02:00
Michael Gmelin 05b27e83b7 Exclude bytewise comparison in certain tests.
These tests never worked - they weren't run before
d5aaeb4.

Note that these tests would fail because of this library
ordering dictionary keys (which is legal). So changing the
input files (or modifying stored cbor/msgpack/ubjson files)
would make the tests work and they could get removed from
"exclude_packaged".

Also move parsing of files in these unit tests to within
the inner sections, so that they're only parsed
number_of_files * number_of_sections instead of
number_of_files * number_of_files * number_of_sections
(so, instead of close to 100k parses about 700).
2018-07-29 14:52:52 +02:00
Michael Gmelin d5aaeb4cce Make section names unique in loops, as catch doesn't support duplicate
sections, see also https://github.com/catchorg/Catch2/issues/816#issuecomment-278268122

As a result, when built with gcc, loop iterations were skipped. When
built with clang, the test aborted with an assertion in catch.hpp
line 6222.

This also addresses the issues discussed here:
https://github.com/nlohmann/json/issues/1032#issuecomment-378707696

and here:
https://github.com/catchorg/Catch2/issues/1241

Please note that this introduces new problems, as some of
the unit tests fail now - the library stores keys in
lexographical order, while the cbor/msgpack/ubjson examples
store them in original order.
2018-07-29 10:44:36 +02:00
Niels Lohmann 3760a38b7e 🏁 implicit conversion is not allowed with MSVC 2018-07-21 11:47:05 +02:00
Niels Lohmann 5b14411669 🏁 trying to fix C2440 error
Error in AppVeyor:

unit-conversions.cpp(441): error C2440: 'initializing': cannot convert from 'nlohmann::json' to 'std::nullptr_t'

(https://ci.appveyor.com/project/nlohmann/json/build/2838/job/wo7im01sq6tvhe9m)
2018-07-21 10:59:00 +02:00
Niels Lohmann 347e77bdc1 🚑 fix for #1169 2018-07-21 10:31:55 +02:00
Niels Lohmann 04372a8c56 🏁 fix for #1168 2018-07-19 17:31:50 +02:00
Hyeon Kim d0e60de433 Add new JSON_INTERNAL_CATCH macro function 2018-07-19 15:43:41 +09:00
Niels Lohmann 7bfc406ded 📝 added note about CocoaPods #1148 2018-07-05 21:18:46 +02:00
Niels Lohmann d456a2d777 Merge pull request #1151 from sonulohani/bigObjFix
Fixed compiler error in VS 2015 for debug mode
2018-06-29 09:03:43 +02:00
Sonu Lohani b8ad3388ec Fixed compiler error in VS 2015 for debug mode
https://github.com/nlohmann/json/issues/1114
2018-06-29 09:34:41 +05:30
Niels Lohmann 39dd775e38 🔨 cleanup after #1134 2018-06-28 21:32:32 +02:00
Niels Lohmann 86a96b059d Merge pull request #1134 from Daniel599/feature/items_iterator
fixed compile error for #1045
2018-06-28 21:21:17 +02:00
Niels Lohmann 396a914f9e 🔨 added macro to disable compiler check #1128 2018-06-26 22:47:40 +02:00
Niels Lohmann bab5826504 Merge pull request #1144 from jrakow/cppreference-link-fix
Fix links to cppreference named requirements (formerly concepts)
2018-06-26 07:58:45 +02:00
Niels Lohmann 515cfc2d89 Merge pull request #1142 from jrakow/develop
meson: fix include directory
2018-06-24 23:33:30 +02:00
Julius Rakow 963d06a13c 📝 fix links to cppreference named requirements
"Concepts" have been renamed to "named requirements".
This is because P0898R3 Standard Library Concepts has been merged into
C++20.
Cppreference have moved their links accordingly.
2018-06-24 22:36:19 +02:00
Julius Rakow 9f00db48d9 📝 link to cppreference via HTTPS 2018-06-24 22:34:47 +02:00
Julius Rakow ec2ebd5ec9 meson: add multiple headers target 2018-06-24 18:07:30 +02:00
Julius Rakow 0bb36bb140 meson: fix include directory 2018-06-24 18:07:30 +02:00
Niels Lohmann 62457729e8 📝 mentioned MinGW in README 2018-06-24 18:03:59 +02:00
Niels Lohmann 09c0df4a21 👷 choosing correct image 2018-06-24 17:40:16 +02:00
Niels Lohmann 1bbc4a0859 👷 using Ninja to speed up build 2018-06-24 17:10:13 +02:00
Niels Lohmann d8fe13fc83 🔨 fixed escaping for MinGW 2018-06-24 16:57:53 +02:00
Niels Lohmann e59b930927 👷 trying a more recent compiler 2018-06-24 16:40:47 +02:00
Niels Lohmann 937d68e2e5 👷 forgot old PATH 2018-06-24 16:37:02 +02:00
Niels Lohmann 989ad9b759 👷 using help from https://stackoverflow.com/a/48509334/266378 2018-06-24 16:35:16 +02:00
Niels Lohmann 067e288289 👷 set build type 2018-06-24 16:29:03 +02:00
Niels Lohmann 7bbc06b487 👷 forgot quotes 2018-06-24 16:18:44 +02:00
Niels Lohmann 441e5d87e6 👷 experimenting with AppVeyor and MinGW 2018-06-24 16:17:06 +02:00
Niels Lohmann 7fa4ddf93e 💄 fixed indentation 2018-06-23 17:27:40 +02:00
Niels Lohmann bf348ca8a4 Merge pull request #1028 from gracicot/develop
Added support for string_view in C++17
2018-06-23 17:10:04 +02:00
Niels Lohmann ed6a0686df 🔨 small refactoring to improve branch coverage
The branch coverage reported by lcov is weird. The code before and after has the same Godbolt assembler, but the code with the lambda has a better branch coverage.
2018-06-23 17:05:04 +02:00
Niels Lohmann c8bfdfd961 👷 tryping different platforms for AppVeyor 2018-06-23 11:12:32 +02:00
Niels Lohmann c02de445bf 🚨 fixed more compiler warnings 2018-06-23 11:00:42 +02:00
Niels Lohmann 66dd1a846d 🚨 fixed more compiler warnings 2018-06-23 10:47:55 +02:00
Niels Lohmann 850922269d 🚨 removed compiler warnings 2018-06-23 10:28:04 +02:00
Niels Lohmann 0460b90977 📝 fix for #1052 #1139 2018-06-22 22:35:48 +02:00
Niels Lohmann 85f35a1d59 📝 documentation fix 2018-06-22 22:34:42 +02:00
Niels Lohmann e7c1638d11 💄 cleanup 2018-06-18 22:03:46 +02:00
Niels Lohmann 1c81e9f5ae Merge pull request #1130 from agrianius/develop
test (non)equality for alt_string implementation
2018-06-18 22:01:53 +02:00
Niels Lohmann d505ed7b31 Merge pull request #1138 from theodelrieu/feature/unordered_map_conversion
Feature/unordered map conversion
2018-06-18 21:59:46 +02:00
Théo DELRIEU 2c920a1032 run make amalgamate 2018-06-18 15:14:10 +02:00
Théo DELRIEU 2b37d7ed86 from_json: add overload for std::unordered_map
Fixes #1133
2018-06-18 15:14:10 +02:00
Théo DELRIEU 299469cfd5 from_json: add missing template arguments for std::map 2018-06-18 10:52:11 +02:00
Danielc 1566ad4053 fixed compile error for #1045; to_json for iternation_proxy_internal was needed 2018-06-16 12:01:49 +03:00
Vitaliy f574d7e084 simplify templates for operators, add more checks 2018-06-14 15:07:06 +03:00
Vitaliy cd28d872e7 forward declarations to make new compilers happy 2018-06-11 20:50:39 +03:00
Vitaliy 3d3055909c define global operator< for const char* and alt_string 2018-06-11 19:09:57 +03:00
Vitaliy 4feb8211ca test (non)equality for alt_string implementation 2018-06-11 18:03:46 +03:00
Guillaume Racicot 14e6278c2f Merge branch 'develop' of github.com:gracicot/json into develop 2018-06-04 11:18:25 -04:00
Guillaume Racicot 7acd90b651 Fixed check for compatible string type 2018-06-04 11:18:19 -04:00
Guillaume Racicot 5676a2a076 Aligned template declaration 2018-06-03 23:51:07 -04:00
Guillaume Racicot e0e7fa39e7 Re-added external_constructor with string compatible types 2018-06-03 23:49:13 -04:00
Guillaume Racicot 4778c02ab5 Set MSVC version from 1514 and older 2018-06-01 14:42:25 -04:00
Guillaume Racicot 714c592680 Disabled implicit conversion to string_view on MSVC 15.13 and older 2018-06-01 14:22:57 -04:00
Niels Lohmann e830bc502f Merge pull request #1117 from TinyTinni/develop
remove stringstream dependency
2018-06-01 08:05:45 +02:00
Matthias Möller ecadcdb593 added char cast
should fix the GCC unittest
2018-05-31 16:36:16 +02:00
Matthias Möller 48656a49f5 typo 2018-05-31 15:32:21 +02:00
Matthias Möller 64acb42aa7 remove stringstream dependency 2018-05-31 13:45:58 +02:00
Niels Lohmann 8efbf8d7bb 📝 documentation to avoid future issues like #1108 2018-05-28 18:14:44 +02:00
Niels Lohmann e5a67fc3f8 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-05-28 17:57:46 +02:00
Niels Lohmann a49644ab74 🚑 adjusted Fuzzer to new parser
out_of_range exceptions where unexpected before - the parser used to crash in these situations...
2018-05-28 17:57:22 +02:00
Niels Lohmann 0efaf891e5 Merge pull request #1089 from theodelrieu/feature/map_conversion
Provide a from_json overload for std::map
2018-05-28 14:53:23 +02:00
Théo DELRIEU c5e63fd684 Provide a from_json overload for std::map
This overload is chosen only when BasicJsonType::string_t
is not constructible from std::map::key_type.

Currently, converting a map to json treats it as an array of pairs.

fixes #1079
2018-05-28 11:06:24 +02:00
Niels Lohmann db03d09312 Merge branch 'feature/key_ref' into develop (fixes #1098) 2018-05-27 22:26:00 +02:00
Niels Lohmann cf9299d222 Merge branch 'feature/sax2' into develop #971 2018-05-27 18:12:59 +02:00
Niels Lohmann 3cdc4d784b 📝 added documentation 2018-05-27 18:07:53 +02:00
Niels Lohmann adf09726b0 Merge branch 'develop' into feature/sax2 2018-05-27 14:26:13 +02:00
Niels Lohmann 481ace65c4 🔨 only calculate array index string when needed #1098 2018-05-27 12:04:22 +02:00
Niels Lohmann 1c6b332dcd 👌 mitigating cppcheck bug #1101 2018-05-26 14:10:13 +02:00
Niels Lohmann 90eb0a91e0 keys are now returned as const reference #1098 2018-05-26 13:26:40 +02:00
Niels Lohmann 1f84cc2c88 adjusted test cases 2018-05-17 16:50:37 +02:00
Niels Lohmann 717301d1bc Merge branch 'testsuite' into feature/sax2 2018-05-17 16:36:43 +02:00
Niels Lohmann 4639bb2c8f added more tests from recent nst's JSONTestSuite 2018-05-17 10:10:01 +02:00
Niels Lohmann e94862a649 🚑 fixed error in callback logic 2018-05-06 19:00:49 +02:00
Niels Lohmann ae213721b1 🔨 removed unget function for wstring parsers 2018-05-06 14:05:29 +02:00
Niels Lohmann 5ff2abb90d Merge branch 'develop' into feature/sax2 2018-05-06 13:29:23 +02:00
Niels Lohmann 567fe9b7a0 Merge pull request #1078 from martin-mfg/patch-1
fix typo in README
2018-05-04 17:04:35 +02:00
martin-mfg 377e956655 fix typo in readme
The README says:
> "The library itself contains of a single header file ..."

I guess "consists of a" is the wording that was intended here. Alternatively, "contains a" might also be what was intended. Either way, I think both versions work equally well and thus choose the one that I believe was intended.
2018-05-03 22:42:52 +02:00
Niels Lohmann 5da596385b Update issue templates 2018-05-03 18:35:56 +02:00
Niels Lohmann 7bbe7bb98f 🔥 removed old issue template 2018-05-03 18:35:21 +02:00
Niels Lohmann 14f01e1981 🔧 update issue templates 2018-05-03 18:32:53 +02:00
Niels Lohmann 86b0732a10 📝 added public key used for commits and releases 2018-05-03 18:11:42 +02:00
Niels Lohmann ed69e50ad2 📄 added SPDX-License-Identifier 2018-05-03 17:41:45 +02:00
Niels Lohmann 5bc4ff9da3 Merge branch 'feature/wstring' into develop 2018-04-29 17:29:57 +02:00
Niels Lohmann fa3e42f826 Merge branch 'develop' into feature/wstring 2018-04-29 13:16:12 +02:00
Niels Lohmann b5d1755dfb 🔥 removed commented-out test cases #1060 2018-04-22 15:41:42 +02:00
Niels Lohmann 0ab8fab338 Merge pull request #1058 from dns13/patch-1
Fix typo
2018-04-17 23:26:00 +05:30
Jan Schöppach 65b4d8251b Fix typo in single_include, too 2018-04-17 13:02:36 +02:00
Jan Schöppach 53fb230098 Fix typo 2018-04-17 12:08:44 +02:00
Niels Lohmann 46ec2fddf8 📝 updated THANKS list 2018-04-10 18:13:37 +02:00
Niels Lohmann b8bfd1140d Merge pull request #1048 from chuckatkins/misc-cmake-packaging-enhancements
Misc cmake packaging enhancements
2018-04-10 17:57:21 +02:00
Chuck Atkins 33a2154f8d Enable target namespaces and build dir project config
CMake convention is to use a project namespace, i.e. Foo::, for imported
targets.  When multiple targets are imported from a project, this looks
like Foo::Bar1 Foo::Bar2, etc.  This adds the nlohmann_json:: namespace to
the exported target names.

This also allows the generated project config files to be used from the
build directory instead of just the install directory.
2018-04-10 09:08:38 -04:00
Niels Lohmann 29362c6ace Merge pull request #1047 from jammehcow/patch-1
Fixed incorrect LLVM version number in README
2018-04-10 08:39:58 +02:00
Niels Lohmann c02a3155d4 👷 added Xcode 9.3 builder
See https://blog.travis-ci.com/2018-04-09-say-bonjour-to-xcode-93-and-macos-high-sierra.
2018-04-10 08:39:28 +02:00
Niels Lohmann 8d8f890771 💩 first try on #1045 2018-04-10 08:29:07 +02:00
James Upjohn 7f20e9ddc7 Fixed incorrect version number in README
clang-900.0.39.2 is from LLVM 9.0.0, not 8.1.0
2018-04-10 17:16:44 +12:00
Chuck Atkins 031b88d315 Make the CMake install dir user-configurable 2018-04-09 11:31:25 -04:00
Guillaume Racicot aaee18ce90 Added test for string conversion with string_view 2018-04-09 11:15:33 -04:00
Niels Lohmann 7c503c64b7 Merge pull request #1043 from coryan/patch-1
Fix trivial typo in comment.
2018-04-09 08:19:56 +02:00
Carlos O'Ryan 4286b16b71 Fix trivial typo in comment.
Not really important, but since I saw it.
2018-04-08 15:46:25 -04:00
Niels Lohmann cf91b4f2bb Merge branch 'develop' into feature/wstring 2018-04-08 11:36:58 +02:00
Niels Lohmann f924df1835 Merge branch 'develop' into feature/sax2 2018-04-08 11:36:44 +02:00
Niels Lohmann acf10d9af7 Merge pull request #1041 from ax3l/topic-spack
Package Manager: Spack
2018-04-08 11:32:35 +02:00
Niels Lohmann e1ea8369ad Merge branch 'develop' into feature/sax2 2018-04-08 09:31:59 +02:00
Niels Lohmann 40f279c59d Merge branch 'feature/issue1021' into develop 2018-04-08 09:28:37 +02:00
Niels Lohmann 18a0271a95 Merge branch 'develop' into feature/issue1021 2018-04-08 09:21:43 +02:00
Axel Huebl 1ae9896387 Package Manager: Spack
I contributed a package to the Spack package manager.

Spack is a flexible package manager that supports multiple versions,
configurations, platforms, and compilers. It is popular in
high-performance computing.
2018-04-08 01:12:49 +02:00
Niels Lohmann 83b143382e Merge pull request #1040 from ax3l/topic-debugViewMSVCcmakeMin
CMake: 3.8+ is Sufficient
2018-04-07 15:14:59 +02:00
Axel Huebl e439a1a9a7 CMake: 3.8+ is Sufficient
The current CMake scripts depend on CMake 3.8+.
This allows us to remove previous work-arounds.
2018-04-07 13:15:44 +02:00
Niels Lohmann 495436a5d5 Merge pull request #1026 from ktonon/develop
Added public target_compile_features for auto and constexpr
2018-04-03 17:34:42 +02:00
Kevin Tonon a35d414c39 Update CMake to latest on Travis 2018-04-03 08:28:07 -04:00
Niels Lohmann 08a7233d1b 🚑 fixed commit 1e08654 2018-04-02 22:38:44 +02:00
Niels Lohmann 1e08654f99 🔨 cleanup 2018-04-02 22:25:17 +02:00
Niels Lohmann aa89c5e048 🔨 removing unget_character() function from input adapters #834 2018-04-02 21:10:48 +02:00
Niels Lohmann 6678eb2b4a improved test coverage #1031 2018-04-02 15:38:49 +02:00
Niels Lohmann 16c5bfeaad 👌 fixed compiler warnings #1031 2018-04-02 13:01:56 +02:00
Niels Lohmann 727dd4664b 🔨 trying to make tests run with MSVC #1031 2018-04-02 12:27:07 +02:00
Niels Lohmann ab89ae4e50 🔨 trying to make tests run with MSVC #1031 2018-04-02 11:34:36 +02:00
Niels Lohmann eb06d0531a 🚧 added input adapter for wide strings #1031 2018-04-01 19:12:36 +02:00
Niels Lohmann ba6edd5634 🔨 cleanup 2018-03-30 00:38:18 +02:00
Niels Lohmann 850671b9f1 🔨 using a vector<bool> for the parser hierarchy 2018-03-29 18:45:43 +02:00
Niels Lohmann 4efa8cdb4c 💚 fixed Valgrind options #1030 2018-03-29 17:19:21 +02:00
Niels Lohmann 830c93fd09 📝 fixed example for operator> #1029 2018-03-29 17:07:55 +02:00
Guillaume Racicot c78dbc366c Added test for conversion to string_view 2018-03-29 01:03:57 -04:00
Guillaume Racicot 53d8d57921 Amalgamate single include 2018-03-29 01:03:36 -04:00
Niels Lohmann 5f723bbec6 🔨 realized callback parser wirh SAX interface #971 2018-03-28 23:39:39 +02:00
Niels Lohmann 896a9db461 🔨 improved code #1021 2018-03-28 19:37:21 +02:00
Kevin Tonon 73cc5089e3 Using target_compile_features to specify C++ 11 standard 2018-03-28 13:11:49 -04:00
Niels Lohmann a9baab76c2 🚑 fix for #1021 2018-03-28 18:20:55 +02:00
Niels Lohmann 4f6b2b6429 🔨 changed SAX interface 2018-03-21 20:12:06 +01:00
Niels Lohmann 2537677e4c improved test coverage 2018-03-20 23:40:01 +01:00
Niels Lohmann 9e1abb4842 improved coverage 2018-03-20 22:39:08 +01:00
Niels Lohmann 1e38ffc014 more tests 2018-03-20 20:04:11 +01:00
Niels Lohmann 25f56ff207 📝 updated documentation 2018-03-20 19:22:18 +01:00
Niels Lohmann 99ecca55c4 improved test coverage 2018-03-20 18:49:10 +01:00
Niels Lohmann 9e07e9b4ec implemented non-throwing binary reader 2018-03-19 22:48:13 +01:00
Niels Lohmann a271ee5f16 ♻️ proper use of SAX parser for binary formats 2018-03-18 23:00:45 +01:00
Niels Lohmann 943d641054 🔨 some refactoring 2018-03-18 16:07:21 +01:00
Niels Lohmann 22929fe189 🚧 started a SAX/DOM/callback parser 2018-03-18 15:13:53 +01:00
Niels Lohmann 375b05a17d 🔨 cleanup 2018-03-17 23:31:18 +01:00
Niels Lohmann 606a25195f improved test coverage 2018-03-17 19:15:59 +01:00
Niels Lohmann c87ffad45c ♻️ implemented a non-recursive parser 2018-03-17 14:46:50 +01:00
Guillaume Racicot 2a5506ed98 Amalgamated headers 2018-03-16 13:16:10 -04:00
Guillaume Racicot 8165707990 basic_json now supports getting many type of strings 2018-03-15 15:35:00 -04:00
Niels Lohmann 27cf05af8d Merge branch 'develop' into feature/sax2 2018-03-14 22:02:19 +01:00
Niels Lohmann d2dd27dc3b Merge branch 'release/3.1.2' into develop 2018-03-14 21:48:03 +01:00
Niels Lohmann 183390c10b Merge branch 'release/3.1.2' 2018-03-14 21:47:50 +01:00
Niels Lohmann 8a6c8cb0f7 🔖 set version to 3.1.2 2018-03-14 21:32:03 +01:00
Niels Lohmann afef474c0d 🔖 set version to 3.1.2 2018-03-14 21:09:27 +01:00
Niels Lohmann a52e8355b8 oops 2018-03-14 17:32:48 +01:00
Niels Lohmann 21410d50af 🏁 moved /Wall to CMake 2018-03-14 17:21:31 +01:00
Niels Lohmann 829ed74d66 🏁 experimenting with /Wall 2018-03-14 07:38:22 +01:00
Niels Lohmann 1262d474eb 🏁 fixed an MSVC warning 2018-03-14 07:32:28 +01:00
Niels Lohmann 282bafae4f 🔨 fixed compilation error 2018-03-14 07:18:42 +01:00
Niels Lohmann abac6a0e84 Merge branch 'develop' into feature/sax2 2018-03-13 23:58:17 +01:00
Niels Lohmann 919d1fef8f Merge pull request #1009 from nlohmann/user_string_parser
Allowing for user-defined string type in lexer/parser
2018-03-13 14:52:59 +01:00
Niels Lohmann 8557151d90 ♻️ adjusting lexer/parser in symmetry to #1006 2018-03-12 19:15:11 +01:00
Niels Lohmann b56ac86471 📝 thanks for #1006 2018-03-12 18:44:19 +01:00
Niels Lohmann 0cab3b2c8e Merge pull request #1006 from agrianius/dump-template
dump to alternative string type, as defined in basic_json template
2018-03-12 18:41:59 +01:00
Niels Lohmann 3d4f6a2940 🔨 cleaner exception interface 2018-03-11 22:47:25 +01:00
Niels Lohmann ad47b0fbde ♻️ refactored binary readers to use a SAX parser 2018-03-11 18:47:38 +01:00
Vitaliy Manushkin 392c033805 test refactoring 2018-03-11 00:29:04 +03:00
Vitaliy Manushkin 51349537fc add unit test: checking dump to alternative string type 2018-03-10 23:59:10 +03:00
Vitaliy Manushkin 830f3e5290 forward alternative string class from output_adapter to output_string_adapter 2018-03-10 23:58:16 +03:00
Vitaliy Manushkin ed6b1464f9 dump to alternate implementation of string, as defined in basic_json template (changes to amalgamated code) 2018-03-10 17:36:51 +03:00
Vitaliy Manushkin faccc37d0d dump to alternate implementation of string, as defined in basic_json template 2018-03-10 17:19:28 +03:00
Niels Lohmann 149d2fd09c 💚 improved test coverage 2018-03-10 11:24:00 +01:00
Niels Lohmann 6399cd3039 Merge branch 'develop' into feature/sax2 2018-03-10 11:07:36 +01:00
Niels Lohmann 6151dfaed7 👌 made changes proposed in #1001 2018-03-10 11:02:58 +01:00
Niels Lohmann 35e43df625 Merge branch 'develop' into feature/sax2 2018-03-09 21:56:30 +01:00
Niels Lohmann 9918523077 📝 cleanup after #1001 2018-03-09 21:31:46 +01:00
Niels Lohmann e737de8941 Merge pull request #1001 from nlohmann/leak
Fix memory leak during parser callback
2018-03-09 21:23:00 +01:00
Niels Lohmann aa8fc2a41c 🚑 hopefully fixed the memory leak 2018-03-08 17:11:15 +01:00
Niels Lohmann 7c1a788893 Merge branch 'develop' into feature/sax2 2018-03-08 07:39:37 +01:00
Niels Lohmann cf60e18c89 🔥 removing failing test (work on this in branch "leak") 2018-03-08 07:39:21 +01:00
Niels Lohmann 97559bb1b2 🔨 trying to fix the leak
Part 1: properly use forwarding
2018-03-08 07:36:56 +01:00
Niels Lohmann 38345fd06c 👌 fixed some more warnings 2018-03-07 22:51:22 +01:00
Niels Lohmann 8b379948d0 🔥 replaced acceptor with SAX parser 2018-03-07 22:40:48 +01:00
Niels Lohmann 303a0c5843 Merge branch 'develop' into feature/sax2 2018-03-07 22:26:01 +01:00
Niels Lohmann d183d34b96 💚 added another test case 2018-03-07 22:25:25 +01:00
Niels Lohmann d2d65bb25b ♻️ refined SFINAE to fix some warnings 2018-03-07 22:01:44 +01:00
Niels Lohmann 476b2e09be 💚 added regression tests for #972 and #977 2018-03-06 20:13:31 +01:00
Niels Lohmann 62030615a0 Merge pull request #986 from theodelrieu/fix/basic_json_conversion
Fix/basic json conversion
2018-03-06 19:27:39 +01:00
Niels Lohmann 5beab80553 🔨 using the SAX-DOM parser 2018-03-06 18:17:07 +01:00
Niels Lohmann faf2546a15 🔨 simplified SAX-DOM parser 2018-03-06 07:19:05 +01:00
Niels Lohmann 5b9d03cfdb 🔨 added SAX-DOM-Parser 2018-03-05 21:06:00 +01:00
Niels Lohmann 9d27429527 🔨 added error messages to SAX interface 2018-03-05 16:46:35 +01:00
Niels Lohmann 86991d5204 Merge branch 'develop' into feature/sax2 2018-03-05 16:16:43 +01:00
Niels Lohmann fdecbf6e1e Merge pull request #992 from bogemic/pvs_studio_fix_misprinted_condition
fixed misprinted condition detected by PVS Studio.
2018-03-05 15:57:57 +01:00
Mike Bogdanov fd30ad8a14 did make amalgamate 2018-03-02 11:47:35 +03:00
Mike Bogdanov 2a2ed799b1 pvs_studio fix. misprinted condition 2018-03-02 11:12:44 +03:00
Niels Lohmann 8d104e6fe3 💚 fixed test case 2018-02-28 22:40:48 +01:00
Niels Lohmann 5773e164bb 🚨 fixed a linter warning 2018-02-28 19:59:54 +01:00
Théo DELRIEU 8711ec6034 support construction from other basic_json types
Before this patch, `basic_json` types with different template arguments
were treated as `CompatibleArrayType`. Which sometimes leads to recursive
calls and stack overflows.

This patch adds a constructor and a `get` overload to deal with
different `basic_json` types.
2018-02-27 16:48:09 +01:00
Théo DELRIEU c22f2d41f3 missing CHECK_NOTHROW in unit-udt 2018-02-27 11:09:53 +01:00
Niels Lohmann 3ff9455332 🔨 added a SAX-DOM-Parser 2018-02-26 23:39:23 +01:00
Niels Lohmann 21352c4d8e ♻️ refactored SAX parser 2018-02-26 20:08:12 +01:00
Niels Lohmann 981e226ca2 Merge branch 'develop' into feature/sax2 2018-02-26 20:07:52 +01:00
Niels Lohmann 1f3d2a3be7 📝 overworked README 2018-02-26 17:37:24 +01:00
Niels Lohmann 13ca723c38 Merge pull request #981 from wla80/develop
Make integration section concise
2018-02-26 16:51:51 +01:00
Wilson 05d3bf1699 Make integration section concise 2018-02-25 22:12:44 -08:00
Niels Lohmann 8d6b3d44d6 👌 fixed some compiler warnings 2018-02-25 18:35:16 +01:00
Niels Lohmann 8c7f46f7d0 🔨 removed a logic error and improved coverage 2018-02-25 17:10:30 +01:00
Niels Lohmann 922f7a3d0e added more tests for SAX parsing 2018-02-25 14:21:30 +01:00
Niels Lohmann ac230e8b4b 🔨 fixed test cases to be more robust 2018-02-25 10:44:47 +01:00
Niels Lohmann 374ebacc51 added a SAX parser #971 2018-02-24 18:04:07 +01:00
Niels Lohmann 8968adcd53 Merge branch 'release/3.1.1' into develop 2018-02-13 19:36:35 +01:00
Niels Lohmann c8ea63a31b Merge branch 'release/3.1.1' 2018-02-13 19:36:20 +01:00
Niels Lohmann 8424d10e45 🔖 set version to 3.1.1 2018-02-13 15:59:32 +01:00
Niels Lohmann 938c861a09 🔖 set version to 3.1.1 2018-02-12 22:59:36 +01:00
Niels Lohmann 94b7a8da66 💄 fixed indentation 2018-02-12 20:46:14 +01:00
Niels Lohmann 20b5f4d89c Merge pull request #969 from theodelrieu/fix/924
Fix constraints on from_json(CompatibleArrayType)
2018-02-12 18:17:59 +01:00
Théo DELRIEU 01d6118828 Fix constraints on from_json(CompatibleArrayType)
Fixes #924
2018-02-12 15:37:33 +01:00
Niels Lohmann b02e3bb0b6 Merge pull request #957 from theodelrieu/fix_coveralls
Make coveralls watch the include folder
2018-02-12 15:02:21 +01:00
Théo DELRIEU 41db7cd818 Make the coveralls job use the multiple header version 2018-02-12 10:23:33 +01:00
Niels Lohmann 447f5421eb 🔨 overworked release target 2018-02-11 16:50:01 +01:00
Niels Lohmann 61f0bfb15c 🔨 enforce using Python 2 for the wandbox script 2018-02-11 14:46:15 +01:00
Niels Lohmann 548f488941 🔨 overworked Makefile 2018-02-10 14:46:39 +01:00
Niels Lohmann 865ff00de0 📝 updated documentation wrt. objects #963 2018-02-09 23:37:20 +01:00
Niels Lohmann addbbbe136 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-02-09 23:32:37 +01:00
Niels Lohmann 0a64982e86 📝 cleanup after #954 2018-02-09 23:32:28 +01:00
Niels Lohmann e5d538c5ea Merge pull request #954 from pfultz2/patch-1
Add a note about installing the library with cget
2018-02-09 23:28:54 +01:00
Niels Lohmann 2dda87c3b7 Merge branch 'feature/coverage_multi' into develop 2018-02-09 23:01:56 +01:00
Paul Fultz II 5731695d7b Clarify dev version and add space after the word flag. 2018-02-09 15:45:20 -06:00
Niels Lohmann 74675dd69c back to the original version 2018-02-09 22:40:52 +01:00
Paul Fultz II 50863c5a09 Latest updates based on feedback 2018-02-09 15:35:46 -06:00
Niels Lohmann ab05df3a48 🔨 another try 2018-02-09 22:27:08 +01:00
Niels Lohmann b455154cc9 🔨 another try 2018-02-09 22:18:51 +01:00
Niels Lohmann 1e8f4d6ab3 🔨 more trying 2018-02-09 22:11:05 +01:00
Niels Lohmann 316634e129 🔨 added quotes around parameters 2018-02-09 21:54:32 +01:00
Niels Lohmann 0111f3187e 🔨 working on #953 2018-02-09 21:30:15 +01:00
Niels Lohmann 83db7876c5 🏁 removing test case that fails on MSVC #962 2018-02-09 18:32:12 +01:00
Niels Lohmann 33a9b00ce6 🐛 fix for #962
Added out_of_range exception for UBJSON containers with sizes that exceed the target container's max_size.
2018-02-06 22:38:53 +01:00
Niels Lohmann 8b457ace25 🐛 fixing CBOR's indefinity length strings #961
Beside the fix discussed in #961, we also had to re-adjust a test case. It seems that it was failing before, and I "fixed" it to work with the broken implementation...
2018-02-06 20:43:03 +01:00
Niels Lohmann 556e30f759 Merge pull request #955 from patrikhuber/patch-1
Fix links in README.md
2018-02-06 20:18:14 +01:00
Patrik Huber ee76436592 Change to angle brackets 2018-02-06 11:29:37 +00:00
Niels Lohmann 737cffe0cb 🔨 fixed directory for lcov coverage 2018-02-04 20:58:50 +01:00
Patrik Huber ae688016f6 Changed links from master to develop branch 2018-02-04 12:41:46 +00:00
Niels Lohmann 2b7b39c72d 🚀 added release target #956 2018-02-04 13:29:23 +01:00
Patrik Huber 44b40d7c6a Fix links in README.md 2018-02-03 15:48:02 +00:00
Paul Fultz II 3402260983 Add a note about installing the library with cget 2018-02-02 11:13:13 -06:00
Niels Lohmann 3a887dc9fe 👷 fixed coveralls 2018-02-02 07:56:30 +01:00
Niels Lohmann 5c2a0a511e 👷 fixed coveralls 2018-02-02 07:31:57 +01:00
Niels Lohmann b779666916 👷 re-added homebrew tests 2018-02-02 00:20:04 +01:00
Niels Lohmann 97309f0da9 Merge branch 'release/3.1.0' into develop 2018-02-02 00:06:17 +01:00
Niels Lohmann 15acf260ca Merge branch 'release/3.1.0' 2018-02-02 00:05:55 +01:00
Niels Lohmann a8fcfd9880 👷 fixed travis file 2018-02-01 22:34:14 +01:00
Niels Lohmann f5c03999d0 🔨 fixed benchmark compilation 2018-02-01 22:26:26 +01:00
Niels Lohmann 0258484626 🔖 set version to 3.1.0
- updated documentation wrt. new repository layout
- temporarily switched off Homebrew --HEAD building (can only be switched on after release)
- set copyright date to 2018
2018-02-01 22:20:26 +01:00
Niels Lohmann ce7d0ebf5d Merge pull request #944 from theodelrieu/fix/cmake_install
fix cmake install directory (for real this time)
2018-02-01 18:39:07 +01:00
Théo DELRIEU 14cd019861 fix cmake install directory (for real this time)
* Rename 'develop' folder to 'include/nlohmann'
* Rename 'src' folder to 'single_include/nlohmann'
* Use <nlohmann/*> headers in sources and tests
* Change amalgamate config file
2018-02-01 11:06:51 +01:00
Niels Lohmann 9958dde3da Merge pull request #950 from kaidokert/develop
Templatize std::string in binary_reader #941
2018-02-01 09:29:53 +01:00
Kaido aed4a080bf Templatize std::string in binary_reader #941 2018-01-31 23:01:01 -08:00
Niels Lohmann e8bf1f62f7 added define for library version #948 #943 2018-01-31 22:36:18 +01:00
Niels Lohmann 552d153842 📝 added more statistics on binary formats 2018-01-31 21:54:38 +01:00
Niels Lohmann 60e2d28eb7 🐛 fix for #947 2018-01-31 20:53:13 +01:00
Niels Lohmann 51c774f208 📝 added documentation for binary formats 2018-01-31 17:23:11 +01:00
Niels Lohmann 57e6fddd90 🚨 fixed warnings 2018-01-30 23:57:49 +01:00
Niels Lohmann f7131715b1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-01-30 23:20:39 +01:00
Niels Lohmann ce273af9b6 📝 added documentation for binary formats 2018-01-30 23:20:36 +01:00
Niels Lohmann ae235139b9 Merge pull request #940 from kaidokert/develop
Allow overriding THROW/CATCH/TRY macros with no-exceptions #938
2018-01-29 22:04:26 +01:00
Niels Lohmann 8049442c2a 🔨 rename yytext to token_buffer (fixes #933) 2018-01-29 21:56:13 +01:00
Kaido d0c9e5fffc Allow overriding THROW/CATCH/TRY macros with no-exceptions (redo) #938 2018-01-28 14:42:13 -08:00
Niels Lohmann b3bd3b726b 📝 added link to OSS-Fuzz project repository 2018-01-28 21:02:02 +01:00
Niels Lohmann 52e9449563 📝 added more functions to overview 2018-01-28 20:44:45 +01:00
Niels Lohmann cb4a9c85cb 🔨 excluded code from coverage 2018-01-28 17:55:40 +01:00
Niels Lohmann 1483d39c91 🔨 moved class json_pointer into separate file #920 2018-01-28 15:36:56 +01:00
Niels Lohmann e95578f884 📝 documented JSON Merge Patch (RFC 7386) 2018-01-28 14:36:17 +01:00
Niels Lohmann 102c474397 🔨 clean up 2018-01-28 14:13:02 +01:00
Niels Lohmann 6855bbb902 🔨 split "parsing" directory to "input" and "output" 2018-01-28 13:15:03 +01:00
Niels Lohmann 05f49fa401 added roundtrip tests for UBJSON 2018-01-27 18:47:32 +01:00
Niels Lohmann f0b26c8f38 added fuzzer for UBJSON input 2018-01-27 18:38:11 +01:00
Niels Lohmann b0a68f540f added roundtrip tests for UBJSON 2018-01-27 18:37:55 +01:00
Niels Lohmann 1be3935e9d 📝 cleanup after #936 2018-01-27 17:43:44 +01:00
Niels Lohmann 7aace7c976 Merge pull request #936 from zerodefect/improvement/fix_kmin_compiler_warning
Removed compiler warning about unused variable 'kMinExp'
2018-01-27 16:51:52 +01:00
Niels Lohmann 0e2211df0e Merge pull request #925 from zerodefect/improvement/improve_readme_json_fwd
Howto installation of json_fwd.hpp (fixes #923)
2018-01-25 17:11:21 +01:00
zerodefect 95cf1fefaa Removed compiler warning about unused variable 'kMinExp'. 2018-01-25 12:51:48 +00:00
Niels Lohmann 355c1e946b 👷 added task to check amalgamation #906
- Builds and runs test cases from individual sources rather than from amalgamation.
- Checks whether amalgamation would create the same single-header file as checked in.
2018-01-23 18:00:12 +01:00
Niels Lohmann dbfd7e532b Merge branch 'develop' of https://github.com/nlohmann/json into develop 2018-01-23 16:33:10 +01:00
Niels Lohmann 3c68a796df 🔥 deprecated iterator_wrapper #874
Also fixed some warnings from GCC.
2018-01-23 16:33:08 +01:00
Niels Lohmann f05c3edc21 Merge pull request #930 from Pipeliner/develop
Fix a typo in README.md
2018-01-23 07:32:23 +01:00
Niels Lohmann f5c4e9f3a1 Merge pull request #919 from theodelrieu/fix/sfinae_for_incomplete_types
fix sfinae on basic_json UDT constructor
2018-01-23 07:32:06 +01:00
Niels Lohmann 7eabb6ba36 📝 updated documentation for UBJSON functions 2018-01-22 23:23:17 +01:00
Vadim Evard fc32b8a9bc Fix a typo in README.md 2018-01-22 13:14:39 +03:00
Niels Lohmann 3cca630836 🔨 cleanup after #915 2018-01-21 15:55:35 +01:00
Niels Lohmann 010e596001 Merge pull request #915 from abolz/dtoa
Floating-point formatting
2018-01-21 15:02:57 +01:00
Niels Lohmann 3d776b0582 📝 updated README 2018-01-21 14:13:42 +01:00
Niels Lohmann 9e5d901f55 Merge branch 'feature/ubjson' into develop 2018-01-21 14:04:29 +01:00
Niels Lohmann 327b8bb09e Merge branch 'feature/strings' into develop 2018-01-21 13:55:52 +01:00
zerodefect d2b3fd156e Updated README.md to explain how installation of json_fwd.hpp can be achieved as part of install step. 2018-01-19 11:42:53 +00:00
Niels Lohmann b406e3704b using Google Benchmark #921 2018-01-18 22:00:32 +01:00
Niels Lohmann a8f711a2f1 using Google Benchmark #921 2018-01-18 21:57:21 +01:00
Niels Lohmann 6402077ac2 Merge pull request #876 from nlohmann/feature/rfc7396
JSON Merge Patch (RFC 7396)
2018-01-18 06:49:31 +01:00
Théo DELRIEU dcee778c1e fix sfinae on basic_json UDT constructor
Avoid compiler errors when performing SFINAE checks on basic_json
and incomplete types.
2018-01-17 12:17:38 +01:00
Niels Lohmann 7456f1d87b ♻️ re-used existing UTF-8 decoder to simplfy string serialization 2018-01-16 20:42:00 +01:00
Niels Lohmann afe4571309 🔨 cleanup + some noexcept 2018-01-16 20:41:04 +01:00
Niels Lohmann b182308eff 🔨 cleanup 2018-01-16 20:40:24 +01:00
abolz 9b9919d460 Use max_digits10 in dump_float for float->text->float round-trip 2018-01-15 21:26:03 +01:00
abolz 810f81bbd9 Regenerate src/json.hpp 2018-01-15 21:24:59 +01:00
abolz 787204f076 Add unit-tests for detail::to_chars 2018-01-15 21:13:17 +01:00
abolz 9f7c2c04c8 Use the Grisu2 algorithm for formatting 'float's and 'double's 2018-01-15 21:07:26 +01:00
abolz 332f352033 Add an implementation of the Grisu2 algorithm for binary to decimal floating-point conversion
This is an attempt to fix #360. The algorithm produces
decimal representations which are guaranteed to roundtrip
and in ~99.8% actually produces the shortest possible
representation. So this is a nice compromise between using
a precision of digits10 and max_digits10.

Note 1:

The implementation only works for IEEE single/double precision
numbers. So the old implementation is kept for compatibility
with non-IEEE implementations and 'long double'.

Note 2:

If number_float_t is 'float', not all serialized numbers can
be recovered using strtod (strtof works, though). (There is
exactly one such number and the result is off by 1 ulp.)
This can be avoided by changing the implementation (the fix
is trivial), but then the resulting decimal numbers are not
exactly short.
2018-01-15 21:07:26 +01:00
abolz 0695ac4001 Add tests for #360 2018-01-15 21:07:25 +01:00
abolz 68a9736738 Tests: Re-enable some round-trip tests 2018-01-15 21:07:25 +01:00
abolz 6e2e466c27 Tests: Don't rely on the format used for floating-point formatting 2018-01-15 21:07:25 +01:00
abolz 107c21a488 Tests: Exponents are formatted with a leading '+' sign 2018-01-15 21:07:25 +01:00
abolz 3ae82d91a2 Tests: Floating-point formatting uses lower case 'e' 2018-01-15 21:07:24 +01:00
Niels Lohmann 92f7295063 🔨 cleanup 2018-01-15 13:21:33 +01:00
Niels Lohmann 3ac674562f 🔨 clean up 2018-01-14 22:26:20 +01:00
Niels Lohmann d9446b0e6e Merge pull request #911 from theodelrieu/fix/cmake_install
Fix/cmake install
2018-01-14 20:08:49 +01:00
Niels Lohmann 9d6b3731b9 improved test coverage 2018-01-14 20:07:38 +01:00
Niels Lohmann 06cddd371b 🔨 removed failing amalgamation test 2018-01-14 17:22:42 +01:00
Niels Lohmann f85f4967fe improved test coverage 2018-01-14 17:22:06 +01:00
Niels Lohmann 6965ff00c8 Merge branch 'develop' into feature/ubjson 2018-01-14 13:58:06 +01:00
Niels Lohmann 411c16cbb2 📝 overworked documentation wrt. amalgamation #906 2018-01-14 13:08:28 +01:00
Niels Lohmann fea5f3792b 📝 it's 2018 2018-01-14 10:41:59 +01:00
Niels Lohmann 541b46132d ♻️ adjusted code to split headers 2018-01-14 10:34:43 +01:00
Niels Lohmann 0e8f01a963 Merge branch 'develop' into feature/rfc7396 2018-01-14 10:28:09 +01:00
Niels Lohmann c772c01a48 ♻️ refactored code to split headers 2018-01-14 10:27:30 +01:00
Niels Lohmann 1b54d4a5aa Merge branch 'develop' into feature/ubjson 2018-01-14 10:10:56 +01:00
Niels Lohmann 420dcf1f25 🚧 added check whether code is amalgamated 2018-01-14 10:10:23 +01:00
Théo DELRIEU 5775084ffc cmake: add option to use/install the non-amalgamated version 2018-01-13 13:07:03 +01:00
Théo DELRIEU 84bffd5d36 move amalgamate tool to third_party folder 2018-01-13 13:05:42 +01:00
Théo DELRIEU 922b56e492 cmake: add back trailing slash to NLOHMANN_JSON_SOURCE_DIR 2018-01-13 12:27:33 +01:00
Niels Lohmann a66b2d20c6 🚨 removed linter warnings for Python code 2018-01-13 11:15:23 +01:00
Niels Lohmann f4a55f26b0 added amalgamate Python script 2018-01-13 10:59:49 +01:00
Niels Lohmann 241eea0c0e 📝 documentation 2018-01-12 09:23:33 +01:00
Niels Lohmann 10bad9381d 🚧 added size benchmark for binary formats 2018-01-10 23:13:48 +01:00
Niels Lohmann 3a7585e738 added more tests 2018-01-10 22:47:07 +01:00
Niels Lohmann 31bfabc4c0 🔨 optimized input format 2018-01-10 16:14:43 +01:00
Niels Lohmann 965a70e38d 🔨 optimized output format 2018-01-10 11:22:19 +01:00
Niels Lohmann 85173f5627 🔨 some clean up 2018-01-10 10:18:31 +01:00
Niels Lohmann ce53537ba2 replaces amalgamation tool
The tool used before created a lot of duplicates inside the generated amalgamation. The new tool is a single Python file which seems to do the same job.
2018-01-09 23:15:06 +01:00
Niels Lohmann 0a2920e0fd ♻️ reorganized code 2018-01-09 18:30:02 +01:00
Niels Lohmann b67e00b9b5 Merge pull request #700 from theodelrieu/refactor/split_it
Refactor/split it
2018-01-09 07:57:01 +01:00
Niels Lohmann fd04967676 🐛 fixed copy-paste error 2018-01-08 21:37:51 +01:00
Niels Lohmann fb1154c237 🚧 debug 2018-01-08 21:26:41 +01:00
Niels Lohmann 97e0d20ce9 🚧 debug 2018-01-08 21:16:20 +01:00
Niels Lohmann ebf28a26ee 🚧 another try 2018-01-08 20:49:02 +01:00
Théo DELRIEU 7e4ee23f40 add single_header CMake target 2018-01-08 20:09:43 +01:00
Théo DELRIEU 57d822b6e2 add missing includes, put back include comments 2018-01-08 20:09:41 +01:00
Théo DELRIEU 9cab30cfce add adl_serializer.hpp 2018-01-08 20:09:38 +01:00
Théo DELRIEU 8e9714fe3d add detail/json_ref.hpp 2018-01-08 20:09:35 +01:00
Théo DELRIEU a3473fda6a add detail/serializer.hpp 2018-01-08 20:09:33 +01:00
Théo DELRIEU c117515e31 add detail/parsing/binary_writer.hpp 2018-01-08 20:09:29 +01:00
Théo DELRIEU d620f76f0d add detail/parsing/binary_reader.hpp 2018-01-08 20:09:27 +01:00
Théo DELRIEU 4dbb433a79 add detail/parsing/output_adapters.hpp 2018-01-08 20:09:24 +01:00
Théo DELRIEU ae6f66048c add detail/iterators/json_reverse_iterator.hpp 2018-01-08 20:09:21 +01:00
Théo DELRIEU 5fc9ef2b90 add detail/iterators/iteration_proxy.hpp 2018-01-08 20:09:18 +01:00
Théo DELRIEU bf06cf6c22 add detail/iterators/iter_impl.hpp 2018-01-08 20:09:15 +01:00
Théo DELRIEU 3e65a65290 add detail/iterators/internal_iterator.hpp 2018-01-08 20:09:13 +01:00
Théo DELRIEU 51ecc31db7 add detail/iterators/primitive_iterator.hpp 2018-01-08 20:09:10 +01:00
Théo DELRIEU 9ea25685a8 add detail/parsing/parser.hpp 2018-01-08 20:09:06 +01:00
Théo DELRIEU 3a0743db97 add detail/parsing/lexer.hpp 2018-01-08 20:09:04 +01:00
Théo DELRIEU 7ab3e8d7b3 add detail/parsing/input_adapters.hpp 2018-01-08 20:09:01 +01:00
Théo DELRIEU 21881606f2 add detail/conversions/to_json.hpp 2018-01-08 20:08:58 +01:00
Théo DELRIEU e0c02c14f0 add detail/conversions/from_json.hpp 2018-01-08 20:08:55 +01:00
Théo DELRIEU 7056b375c4 add detail/value_t.hpp 2018-01-08 20:08:52 +01:00
Théo DELRIEU 8c555db970 add detail/exceptions.hpp 2018-01-08 20:08:50 +01:00
Théo DELRIEU f364f5ac5a add detail/meta.hpp 2018-01-08 20:08:47 +01:00
Théo DELRIEU d686713f91 add detail/macro_{un}scope.hpp 2018-01-08 20:08:44 +01:00
Théo DELRIEU 5bffc95773 add json_fwd.hpp 2018-01-08 20:08:38 +01:00
Niels Lohmann 3d7658da89 🚧 working on AppVeyor's errors 2018-01-08 19:48:18 +01:00
Niels Lohmann 126ce2e56c 🚧 further UBJSON 2018-01-08 18:54:17 +01:00
Niels Lohmann c9938ea838 🚧 started UBJSON implementation 2018-01-07 22:09:12 +01:00
Niels Lohmann 15b6421d07 added UTF-8 decoder capability and stress test
As described in http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt; Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2015-08-28 - CC BY 4.0
2018-01-05 23:26:22 +01:00
Niels Lohmann 78f8f837e6 added items() function #874 2018-01-05 18:34:10 +01:00
Niels Lohmann 96b40b27a5 📝 fixed Doxygen warnings
Apparently, using "\n" inside an alias is an error now, but "^^" basically means the same.
2018-01-05 18:33:42 +01:00
Niels Lohmann 337e9824ea Merge pull request #900 from Dobiasd/patch-1
fix link to the documentation of the emplace function
2018-01-04 17:11:18 +01:00
Tobias Hermann ba2316372a fix link to the documentation of the emplace function 2018-01-03 11:06:32 +01:00
Niels Lohmann a43347e1f9 Merge branch 'develop' 2017-12-29 20:35:02 +01:00
Niels Lohmann ce1dccf347 Merge branch 'release/3.0.1' into develop 2017-12-29 20:24:49 +01:00
Niels Lohmann 5681e55da8 Merge branch 'release/3.0.1' 2017-12-29 20:24:20 +01:00
Niels Lohmann 92484f0caf 🔖 set version to 3.0.1 2017-12-29 18:31:13 +01:00
Niels Lohmann ebc6849b71 added test for #894 2017-12-29 16:53:04 +01:00
Niels Lohmann 3c76ff353d 📝 updated docs after PRs 2017-12-29 16:52:09 +01:00
Niels Lohmann d45183d426 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-12-28 13:52:26 +01:00
Niels Lohmann 3b3b6e8e69 🚑 fix for #894
- Implemented "copy" in terms of "add".
- Added check for JSON Pointer array indices to make sure the complete reference token was processed.
- Added test suite from https://github.com/json-patch/json-patch-tests
2017-12-28 13:52:23 +01:00
Niels Lohmann f28fc2261a Merge pull request #858 from mattismyname/develop
🔧 Fix up a few more effc++ items
2017-12-28 12:13:19 +01:00
Matthew K. Gumbel 72bff90ed9 🔧 Fix up a few more effc++ items 2017-12-24 10:03:36 -08:00
Niels Lohmann 3113a52a7d 📝 added exception 403 to documentation of at (#888)
The at function throws json::out_of_range.403 when a nonexistent object key is provided (just like the usual at function). This was not documented and users could assume json::out_of_range.404 would be thrown instead.

- Updated documentation.
- Added example code.
2017-12-23 18:38:18 +01:00
Niels Lohmann 184e9c6aa7 Merge pull request #885 from TinyTinni/develop
Includes CTest module/adds BUILD_TESTING option
2017-12-23 11:09:46 +01:00
Matthias Möller d1cda6888e includes CTest module resp. BUILD_TESTING option 2017-12-20 17:54:45 +01:00
Niels Lohmann 88ddb12afc 📝 fix for #883
- Adjusted table to user-defined exceptions. This was forgotten in the 3.0.0 update.
- Added update function to the table.
2017-12-18 19:46:53 +01:00
Niels Lohmann e54b6ace94 Merge pull request #882 from erengy/fix-msvc-c4819
Fix MSVC warning C4819
2017-12-17 19:52:57 +01:00
Eren Okka ab0e8b2f3a Fix MSVC warning C4819
Replaces a U+00A0 character with regular space, and fixes a typo.
2017-12-17 18:02:55 +03:00
Niels Lohmann 1ca6ec1dc0 Merge pull request #880 from nlohmann/coverity_scan
Merge branch 'develop' into coverity_scan
2017-12-17 11:24:40 +01:00
Niels Lohmann 1856f38c85 📝 removed paragraph on version 3.0.0 2017-12-17 11:22:35 +01:00
Niels Lohmann afebb6a3bb Merge branch 'release/3.0.0' into develop 2017-12-17 11:04:53 +01:00
Niels Lohmann 9f81beb5e2 Merge branch 'release/3.0.0' 2017-12-17 11:04:04 +01:00
Niels Lohmann 106f9f5436 ⬆️ updated git-update-ghpages script 2017-12-17 10:20:30 +01:00
Niels Lohmann 9eb5e2c271 🔖 set version to 3.0.0 2017-12-17 08:40:19 +01:00
Niels Lohmann 9e3c4ad11f 🔖 set version to 3.0.0 2017-12-17 08:31:18 +01:00
Niels Lohmann 314e4e7699 📝 improved documentation for dump and iterator_wrapper 2017-12-16 23:58:10 +01:00
Niels Lohmann 9a51fb4da2 🚨 fixed some warnings 2017-12-16 22:19:30 +01:00
Niels Lohmann 7bf007f2bc Merge pull request #879 from nlohmann/feature/algorithms
 re-added tests for algorithms
2017-12-16 12:41:07 +01:00
Niels Lohmann 980795b644 ✏️ fixed typos 2017-12-16 12:37:44 +01:00
Niels Lohmann f3bd755cab removing <iomanip> header 2017-12-16 12:37:25 +01:00
Niels Lohmann 4c871c58f8 re-added tests for algorithms 2017-12-16 11:16:34 +01:00
Niels Lohmann c23f5dcea6 📝 fixed year 2017-12-15 23:49:37 +01:00
Niels Lohmann 2e1b1061cd Merge pull request #875 from nlohmann/feature/spelling
Overworked library toward 3.0.0 release
2017-12-14 22:31:19 +01:00
Niels Lohmann 261caec2de 👥 added contributor image 2017-12-14 22:29:39 +01:00
Niels Lohmann f80827d068 Merge pull request #873 from nlohmann/feature/issue872
🚨 remove C4996 warnings #872
2017-12-14 09:35:48 +01:00
Niels Lohmann 9a70c60fa5 Revert "⬆️ updated to Catch 2.0.1"
This reverts commit 920f64c01c.
2017-12-14 07:49:16 +01:00
Niels Lohmann fb8482db76 👌 fixed some issues from the last commit #875 2017-12-13 23:44:53 +01:00
Niels Lohmann c6e7eae394 implemented JSON Merge Patch (RFC 7396)
SQLite's json1 extension (https://www.sqlite.org/json1.html) supports JSON Merge Patch (https://tools.ietf.org/html/rfc7396). As the implementation is trivial and we already support JSON Patch, I think this could be a nice extension to the library.
2017-12-13 23:36:22 +01:00
Niels Lohmann 920f64c01c ⬆️ updated to Catch 2.0.1
Update required all CHECK_THROWS_AS macros to pass the exception type without reference, because this is now done by Catch2.
2017-12-13 22:18:05 +01:00
Niels Lohmann 293748a9a9 📝 overworked README
- Added recent contributors to thanks list.
- Linked PGP key for private mails.
- Updated compiler list.
2017-12-13 22:17:02 +01:00
Niels Lohmann e8d9963abe 👌 cosmetic changes and overworked spelling
- All hex literals use upper case letters after the x.
- Fixed sime typos.
- Documented some more functions.
2017-12-13 22:15:53 +01:00
Niels Lohmann a9a4ff61c6 🚨 remove C4996 warnings #872
These were the remaining direct calls to alloc.
2017-12-13 17:01:39 +01:00
Niels Lohmann f7ae143a93 Merge pull request #870 from nlohmann/feature/issue838
💥 throwing an exception in case dump encounters a non-UTF-8 string #838
2017-12-13 06:34:11 +01:00
Niels Lohmann 8419bfbbd2 improved test coverage
As we guarantee proper UTF-8 before, we do not need to cope with it later.
2017-12-12 20:44:57 +01:00
Niels Lohmann 569d275f65 💥 throwing an exception in case dump encounters a non-UTF-8 string #838
We had a lot of issues with failing roundtrips (i.e., parse errors from serializations) in case string were stored in the library that were not UTF-8 encoded. This PR adds an exception in this case.
2017-12-11 22:38:05 +01:00
Niels Lohmann 383743c6c0 Merge pull request #868 from nlohmann/feature/issue867
📝 fixing documentation #867
2017-12-11 08:55:26 +01:00
Niels Lohmann 7de009edd1 ✏️ fixing typos #869 2017-12-10 13:07:47 +01:00
Niels Lohmann 772bb3cc20 📝 fixing documentation #867
The example in the documentation on how to "force" an array of arrays was wrong since the first release. Fixed the documentation and added checks for the README unit tests.
2017-12-10 12:32:20 +01:00
Niels Lohmann 0693945230 Merge pull request #860 from bogemic/std_iterator_conformance_cpp17
iter_impl template conformance with C++17
2017-12-08 07:55:47 +01:00
Mike Bogdanov 64d6daa76e iter_impl template conformance with C++17 2017-12-07 11:30:17 +03:00
Niels Lohmann 7c2d4f1852 👷 added Xcode 9.1 and 9.2 2017-12-06 22:32:03 +01:00
Niels Lohmann 9e2f185ac6 💄 reformatted code after PRs 2017-12-06 22:21:11 +01:00
Niels Lohmann c5e731774a Merge pull request #856 from bogemic/std_allocator_conformance_cpp17
Std allocator conformance cpp17
2017-12-06 21:52:52 +01:00
Niels Lohmann 25d205c16d 📝 clarified difference between serialization and string value retrieval #853 2017-12-06 21:42:36 +01:00
Niels Lohmann fa76f2efd7 Merge pull request #855 from theodelrieu/fix/cmake_include_directories
cmake: use BUILD_INTERFACE/INSTALL_INTERFACE
2017-12-06 20:47:38 +01:00
Mike Bogdanov 8890b935fd fixed merge conflicts 2017-12-06 12:24:50 +03:00
Mike Bogdanov daba1b6a0b fixed conformance with C++17, some members of allocator are depricated and should be used via allocator_traits 2017-12-06 11:20:42 +03:00
Niels Lohmann 0e3a0b730b Merge pull request #854 from theodelrieu/fix/force_msvc_stacktrace
to/from_json: add a MSVC-specific static_assert to force a stacktrace
2017-12-05 19:36:31 +01:00
Théo DELRIEU 541ee62a05 cmake: use BUILD_INTERFACE/INSTALL_INTERFACE in target_include_directories 2017-12-05 11:27:03 +01:00
Théo DELRIEU c9a02cbc59 to/from_json: add a MSVC-specific static_assert to force a stacktrace 2017-12-05 10:52:55 +01:00
Niels Lohmann f4c01601fa Merge pull request #844 from TinyTinni/develop
Add .natvis for MSVC debug view
2017-12-04 21:43:22 +01:00
Matthias Möller 24fe572d98 missing new line 2017-11-30 13:37:58 +01:00
Matthias Möller 8e9a8792a9 moved natis to root dir 2017-11-30 13:26:45 +01:00
Matthias Möller af775ddbb8 add compiler & cmake version check 2017-11-28 23:43:39 +01:00
Matthias Möller 48d7a32daa add .natvis for MSVC debug view 2017-11-26 10:31:33 +01:00
Matthias Möller 5b4855dea2 fix targetname 2017-11-26 10:29:51 +01:00
Niels Lohmann cc937deaf6 🚑 the last commit contained a bug #821 2017-11-26 10:15:23 +01:00
Niels Lohmann 430f03512c 🚨 fixed some warnings #821 2017-11-25 22:06:18 +01:00
Niels Lohmann ea5aed0769 Merge branch 'feature/to_array' into develop 2017-11-25 19:41:11 +01:00
Niels Lohmann de75cf89f7 improved test coverage 2017-11-25 19:41:02 +01:00
Niels Lohmann 52ca35b2b0 Merge pull request #829 from jowr/patch-1
Updated hunter package links
2017-11-18 13:35:21 +01:00
Jorrit Wronski 7b8ddadd83 removed hunter badge 2017-11-16 21:01:27 +01:00
Jorrit Wronski b5ddd99adf Updated hunter package links 2017-11-15 08:48:11 +01:00
Niels Lohmann 4c4f60f438 📝 fixes #820 2017-11-06 20:35:05 +01:00
Niels Lohmann 1af5601a2a Merge pull request #811 from Itja/patch-1
Typos README
2017-10-31 18:23:42 +01:00
Itja e423aea64a Typos README
Hey, thanks for this great library which I've used in many occasions now. I know it's not much, but I wanted to contribute at least a tiny bit back to you by this PR :-) Keep up the good work!
2017-10-31 16:31:14 +01:00
Niels Lohmann 5696660eba 🔨 another try to fix #714
adding std::ios_base::binary when opening all_unicode.json.cbor
2017-10-31 15:04:14 +01:00
Niels Lohmann c4d6626745 🚀 installed Request Info Bot 2017-10-30 16:04:34 +01:00
Niels Lohmann 6d2981db82 📝 overworked templates 2017-10-29 16:32:23 +01:00
Niels Lohmann 87df1d6708 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-10-29 11:55:04 +01:00
Niels Lohmann fa1425b87c 🚀 installed Sentiment Bot 2017-10-29 11:54:53 +01:00
Niels Lohmann 73d0095154 Merge pull request #807 from theodelrieu/fix/805
add forwarding references to json_ref constructor
2017-10-28 15:33:22 +02:00
Théo DELRIEU 4b46abf97c add forwarding references to json_ref constructor
fixes #805
2017-10-28 14:22:57 +02:00
Niels Lohmann 8e067c0c3c 🔨 set bidirectional iterator tag #593 2017-10-28 09:41:35 +02:00
Niels Lohmann cea3f24ff9 📝 comment to address #561 2017-10-27 16:39:52 +02:00
Niels Lohmann 61cc07ff38 📝 some documentation 2017-10-27 16:07:04 +02:00
Niels Lohmann 734e2b73cf 🔨 cleanup 2017-10-27 11:49:24 +02:00
Niels Lohmann 7820b5eccb 📝 thanks for #795 2017-10-27 11:49:17 +02:00
Niels Lohmann 77f8e2f987 Merge pull request #795 from jseward/develop
Add transparent comparator and perfect forwarding support to find() and count()
2017-10-27 11:47:23 +02:00
Niels Lohmann c215b77936 🚀 installed Stale Bot 2017-10-25 11:37:33 +02:00
Jamie Seward 992c836b30 Add missing spaces 2017-10-24 00:14:25 -07:00
Jamie Seward 715c98b404 Remove extra spaces 2017-10-24 00:06:22 -07:00
Jamie Seward 6c9a401ebc Remove old non-perfect forwarding find and count 2017-10-24 00:01:56 -07:00
Jamie Seward 16ffdbcb20 Remove c++17 support flag in cmake
Already covered by AppVeyor
2017-10-23 23:50:06 -07:00
Jamie Seward 73b1629a15 Remove tabs for spaces 2017-10-23 23:45:39 -07:00
Niels Lohmann 1b1bd0e3e6 #714 is still not fixed 2017-10-23 12:01:50 +02:00
Jamie Seward 33c6511dd0 Remove JSON_HAS_STRING_VIEW
Instead implement @gregmarr's PR comments that perfect forwarding should be used. Also cleaned up cpp language standard detection.
2017-10-23 00:43:26 -07:00
Niels Lohmann 89650c99dd 🚧 checking if #714 is now fixed with MSVC
Hopefully, #764 fixed this.
2017-10-22 11:16:33 +02:00
Niels Lohmann b0c380b0f8 📝 cleanup after the last PRs 2017-10-22 09:12:35 +02:00
Niels Lohmann be4fba7baf Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-10-22 08:53:46 +02:00
Niels Lohmann f193427e91 🔨 some simplifications 2017-10-22 08:53:43 +02:00
Niels Lohmann 24b6e028a9 improved test coverage 2017-10-22 08:53:27 +02:00
Niels Lohmann 3094640446 Merge pull request #764 from pjkundert/develop-simplify-istream
Simplified istream handing #367
2017-10-22 08:52:28 +02:00
Niels Lohmann ef40673acb Merge branch 'develop' into develop-simplify-istream 2017-10-22 08:52:15 +02:00
Jamie Seward d468f8c4e6 Use consistent logic to determine if string_view exists 2017-10-21 16:36:05 -07:00
Jamie Seward 59cde1ad6e Fix for _HAS_CXX17 == 0
Copied from solution to https://github.com/nlohmann/json/issues/464
2017-10-21 16:29:37 -07:00
Jamie Seward 1a66679929 Add string_view support
This avoids unnecessary string copies on often used
find().
2017-10-21 15:20:13 -07:00
Niels Lohmann 33df3250c3 Merge pull request #793 from sonulohani/develop
Error : 'identifier "size_t" is undefined' in linux
2017-10-21 10:58:27 +02:00
Sonu Lohani 92da334862 Error : 'identifier "size_t" is undefined' in linux 2017-10-21 12:52:44 +05:30
Niels Lohmann 2e281ba64b Merge pull request #788 from jseward/develop
Fix Visual Studio 2017 warnings
2017-10-18 15:04:24 +02:00
Jamie Seward a99fcb4e7d Add comments and newline 2017-10-17 22:53:35 -07:00
Jamie Seward 917d9d8bc3 Fix Visual Studio 2017 warnings 2017-10-16 23:23:55 -07:00
Niels Lohmann 7c8f0a4186 Merge pull request #785 from jseward/develop
Fix warning C4706 on Visual Studio 2017 - fixes #784
2017-10-16 19:48:17 +02:00
Niels Lohmann b27a142ec0 Merge pull request #783 from eld00d/patch-1
Set GENERATE_TAGFILE in Doxyfile
2017-10-16 17:54:28 +02:00
Perry Kundert a8cc7a1bc8 Consistently use std::char_traits int_type-->char conversion intrinsics 2017-10-16 08:06:10 -07:00
Jamie Seward af99090742 Disable warning C4389: '==': signed/unsigned mismatch
Lots of tests have this warning.

Also moved out of for loop, doesn't need to be done every loop.
2017-10-16 01:02:48 -07:00
Jamie Seward 8ba7f69ab4 Fix whitespace 2017-10-16 00:49:59 -07:00
Jamie Seward 8a4af820c7 Fix warning C4706 2017-10-16 00:41:58 -07:00
Jamie Seward 19f8f1c075 Add missing "u8"
This causes test-udt to crash due to bad iterator
2017-10-16 00:21:38 -07:00
Jamie Seward 5ec44fe9e3 Add /W4 for MSVS 2017-10-15 22:56:38 -07:00
Nate Vargas 727ee7d03e Set GENERATE_TAGFILE in Doxyfile
Allows documentation to be linked from other projects to https://nlohmann.github.io/json using Doxygen with the tag:
TAGFILES = $(SOME_PATH)/nlohmann_json.tag=https://nlohmann.github.io/json
2017-10-14 19:06:38 -05:00
Niels Lohmann d300a8e268 🚨 fixed warnings #776 2017-10-13 08:46:29 +02:00
Perry Kundert 0b803d0a5f Simplify the json/src/benchmarks.cpp to allow more optimal code gen.
o For some unknown reason, the complexity of the benchmark platform
  prevented some C++ compilers from generating optimal code, properly
  reflective of the real performance in actual deployment.
o Added the json_benchmarks_simple target, which performs the same
  suite of tests as json_benchmarks.
o Simplified the benchmark platform, and emit an "Average" TPS
  (Transactions Per Second) value reflective of aggregate parse/output
  performance.
2017-10-07 15:50:19 -07:00
Perry Kundert 23440eb86e Remove outdated commentary about the value of eof(), retain input type
o We assume the same character int_type as the unerlying std::istream
o There are no assumptions on the value of eof(), other than that it
  will not be a valid unsigned char value.
o To retain performance, we do not allow swapping out the underlying
  std::streambuf during our use of the std::istream for parsing.
2017-10-06 12:54:43 -07:00
Perry Kundert 45e1e3d48a Revert some unnecessary member initializer changes. 2017-10-06 07:53:31 -07:00
Perry Kundert 5e480b56d8 Further simplify character type handling 2017-10-06 07:37:49 -07:00
Perry Kundert 1b43a45bec Implement correct handling of std::streambuf int_type, eof()
o Make no assumptions about eof(), other than that it is somewhere
  outside of the valid range of char_type.
2017-10-05 16:16:41 -07:00
Perry Kundert 184dab60e6 Accelerate access to underlying std::istream streambuf 2017-10-05 16:16:41 -07:00
Perry Kundert f775922ca8 Specify initializers for yytest, token_string using initializer-lists
o We can retain -Weffc++ and specify default initializers by using
  initializer lists.  The risks are low (of additional non-conformat
  compilers), because there is already one other such initialization
  used in the code-base.
2017-10-05 16:16:41 -07:00
Perry Kundert 546e148b24 Further performance improvements, and corrections in get_token_string
o An (-'ve valued, typically -1) EOF must never be allowed in
  token_string, as it be converted to 255 -- a legitimate value.
o Comparing against a specific eof() (-1, typically) is more costly than
  detecting +'ve/-'ve.  Since EOF is the only non-positive value allowed
  we can use the simpler test.
o Removed unnecessary test for token_string size, as it is already
  tested in the method, and must never occur in correct code; used an
  assert instead.
2017-10-05 16:16:41 -07:00
Perry Kundert 8665e25942 Rename get_string to move_string to imply side-effect 2017-10-05 16:16:41 -07:00
Perry Kundert e0d890cc23 Corrected unnnecessary const restriction on returned std::string 2017-10-05 16:16:41 -07:00
Perry Kundert 97a388802d Improve performance by constructing yytext as a std::string
o Return its contents when necessary.  In many cases, this avoids
  construction of multiple copies of the yytext token.  Exceeds
  performance of current develop branch.
2017-10-05 16:15:46 -07:00
Perry Kundert 7c523338c5 Remove unnnecessary NUL termination of yytext (as it may contain NULs) 2017-10-05 16:01:41 -07:00
Perry Kundert 14ca1f6f09 Restore istream performance #764
o Use std::streambuf I/O instead of std::istream; does not maintain
  (unused) istream flags.
o Further simplify get/unget handling.
o Restore original handling of NUL in input stream; ignored during
  token_string escaping.
2017-10-05 16:01:41 -07:00
Perry Kundert 12efeadc2e Further simplify istream handling; use native unget 2017-10-05 16:01:41 -07:00
Perry Kundert f585fe4eec Test to confirm parsing of multiple JSON records in a istream #367 2017-10-05 16:01:41 -07:00
Perry Kundert 90adf6ec20 Simplify get_token_string, unnecessary buffering, handle Byte Order Mark 2017-10-05 16:01:41 -07:00
Niels Lohmann 0c0851dbea 📝 comment how to integrate tsl::ordered_map (#546) 2017-10-05 20:36:18 +02:00
Niels Lohmann bab4a15748 📝 comment how to integrate fifo_map (#485) 2017-10-05 20:33:27 +02:00
Niels Lohmann 60439aff05 📝 different cmake call 2017-10-05 19:43:59 +02:00
Niels Lohmann 73d1b55aba 🔧 executing tests in parallel 2017-10-05 19:43:39 +02:00
Niels Lohmann 615366447a 🔧 removing -Weffc++ warnings 2017-10-05 19:43:19 +02:00
Niels Lohmann 73727c989c Merge branch 'feature/coveralls' into develop 2017-10-05 19:08:28 +02:00
Niels Lohmann 75f4678b96 🔨 added filter script for branch coverage 2017-10-05 19:08:15 +02:00
Niels Lohmann c204ac82e0 🔨 adjusted Coverity script to work without Makefile 2017-10-05 07:13:59 +02:00
Niels Lohmann 7b82e4b4c8 🔨 added Makefile target to calculate lcov coverage 2017-10-05 00:17:09 +02:00
Niels Lohmann 1b3df3a63f 🔨 trying to use Coveralls with CMake #698 2017-10-04 22:18:21 +02:00
Niels Lohmann 99ee4c1eaf 🔨 cleaned up Makefiles and docs #698 2017-10-04 19:27:35 +02:00
Niels Lohmann 5cb6d7187d 🚨 fixing last warning in #755 2017-10-04 17:28:35 +02:00
Niels Lohmann 4e81c1db47 Merge pull request #765 from nlohmann/feature/issue698
using more CMake
2017-10-04 10:39:56 +02:00
Niels Lohmann e2045eae53 🏁 and another try 2017-10-03 18:47:08 +02:00
Niels Lohmann a85bc358f7 🏁 another try 2017-10-03 18:21:40 +02:00
Niels Lohmann 3457e7bc5b 🏁 try to get MSVC 2017 running again 2017-10-03 17:57:40 +02:00
Niels Lohmann 54bd1b5124 Merge branch 'develop' into feature/issue698 2017-10-03 17:23:05 +02:00
Niels Lohmann 7435d54e97 🔨 clean up 2017-10-02 23:06:41 +02:00
Niels Lohmann 4912231450 Merge branch 'develop' into feature/issue698 2017-10-02 18:25:25 +02:00
Niels Lohmann b91805e1f0 🚨 removing a compiler warning #755 2017-10-02 18:11:36 +02:00
Niels Lohmann f89f8b2d0b Merge branch 'develop' into feature/issue698 2017-10-02 17:47:53 +02:00
Niels Lohmann 8be303d4fb 🏁 fixing a min() call for MSVC #762 2017-10-02 13:54:14 +02:00
Niels Lohmann 1df836ce40 removed call to std::signbit #761 2017-10-01 15:48:29 +02:00
Niels Lohmann 8af49d4be5 🚨 removing compiler warnings #755 2017-09-30 11:00:26 +02:00
Niels Lohmann 1a66527dca 📝 fixed documentation #745 2017-09-30 10:18:18 +02:00
Niels Lohmann b05ea3de55 Merge pull request #753 from gregmarr/patch-1
Add info for the vcpkg package.
2017-09-26 22:36:36 +02:00
gregmarr ec60ff3451 Add info for the vcpkg package. 2017-09-26 08:39:38 -07:00
Niels Lohmann 647711fad1 improved test coverage 2017-09-14 17:31:28 +02:00
Niels Lohmann 737816d0cd 👷 another try with Travis 2017-09-14 17:31:14 +02:00
Niels Lohmann e75adc21a5 Merge branch 'develop' into feature/issue698 2017-09-13 18:57:25 +02:00
Niels Lohmann b90529c36d improved test coverage 2017-09-13 18:56:54 +02:00
Niels Lohmann 82c93680d1 Merge branch 'develop' into feature/issue698 2017-09-10 22:38:23 +02:00
Niels Lohmann e2e0ecd867 improved test coverage 2017-09-10 22:38:04 +02:00
Niels Lohmann 248db1e423 Merge branch 'develop' into feature/issue698 2017-09-10 11:42:57 +02:00
Niels Lohmann 7410763731 improved test coverage 2017-09-10 11:42:43 +02:00
Niels Lohmann cafc2d057a Merge branch 'develop' into feature/issue698 2017-09-10 10:22:10 +02:00
Niels Lohmann da97cf7895 improved test coverage 2017-09-10 10:21:53 +02:00
Niels Lohmann 295d65ada7 Merge branch 'develop' into feature/issue698 2017-09-10 01:13:43 +02:00
Niels Lohmann fcba9ec537 🔨 clean up 2017-09-10 01:12:03 +02:00
Niels Lohmann 41994ba028 Merge branch 'develop' into feature/issue698 2017-09-09 16:53:37 +02:00
Niels Lohmann b21d7810fa improved test coverage 2017-09-09 16:53:27 +02:00
Niels Lohmann c1d6478584 Merge branch 'develop' into feature/issue698 2017-09-09 13:07:40 +02:00
Niels Lohmann 9ae6796a38 improved test coverage 2017-09-09 13:07:10 +02:00
Niels Lohmann 31ce7e1e59 Merge branch 'develop' into feature/issue698 2017-09-09 11:05:20 +02:00
Niels Lohmann fd250ae2b1 improved test coverage 2017-09-09 11:04:58 +02:00
Niels Lohmann 5c08b84dec back to previous MSVC 2017 2017-09-06 18:26:52 +02:00
Niels Lohmann da14286abb 👷 try to use MSVC 2017 again 2017-09-06 18:13:35 +02:00
Niels Lohmann c607b5c2ac 📝 improved documentation 2017-09-06 17:14:06 +02:00
Niels Lohmann 91e0032853 📝 improved documentation 2017-08-29 23:46:26 +02:00
Niels Lohmann b41b13047c 👷 removed unneccessary test 2017-08-27 11:30:36 +02:00
Niels Lohmann 15e757c42b 🔨 trying to fix memory issue with valarray 2017-08-27 10:41:39 +02:00
Niels Lohmann 0e94ba8857 👷 using the same compilers 2017-08-26 08:56:34 +02:00
Niels Lohmann 4f5c345817 👷 run sanitizer another time to check if it works 2017-08-26 08:20:37 +02:00
Niels Lohmann 8608f42187 👷 trying to use libstdc++
https://github.com/travis-ci/apt-source-whitelist/issues/372#issuecomment-320547215
2017-08-25 22:49:18 +02:00
Niels Lohmann 5e7acbf05e 👷 adjusted flags for Clang sanitizer
we are overrding the CXXFLAGS provided by travis in order to use gcc's libstdc++
2017-08-25 22:34:00 +02:00
Niels Lohmann 268f5a3d0a 👷 added option to switch off exceptions 2017-08-25 21:29:27 +02:00
Niels Lohmann 839681ff9f 👷 using Ninja 2017-08-25 21:01:07 +02:00
Niels Lohmann 3dcd360139 👷 adding status messages 2017-08-25 20:19:58 +02:00
Niels Lohmann 05b97c473a 👷 added flags for Valgrind and Clang sanitizer 2017-08-25 20:12:21 +02:00
Niels Lohmann c87b080cc5 👷 new cmake file for test cases 2017-08-25 18:06:22 +02:00
Niels Lohmann 5b71bf09a1 Merge pull request #708 from theodelrieu/fix/from_json_tuple_pair
fix from_json implementation for pair/tuple
2017-08-24 12:40:16 +02:00
Théo DELRIEU bb1b4c934e fix from_json implementation for pair/tuple
Introduced by 6e4910d5c5

Fixes #707
2017-08-23 10:05:43 +02:00
Niels Lohmann e45eaf6e30 Revert "👷 using libc++ with Clang"
This reverts commit 41b2c69bdb.
2017-08-23 08:39:19 +02:00
Niels Lohmann 0b5e8f859b 🔨 cleanup
Fixed some warning in Clion.
2017-08-23 00:42:15 +02:00
Niels Lohmann 9fd031b6f4 🐛 re-added support for std::valarray #702 2017-08-22 23:28:23 +02:00
Niels Lohmann 41b2c69bdb 👷 using libc++ with Clang 2017-08-22 22:04:38 +02:00
Niels Lohmann cd53790993 👷 using Clang 5.0 2017-08-21 20:03:24 +02:00
Niels Lohmann e569b9736b 👷 trying to fix build error
See http://help.appveyor.com/discussions/problems/7450-build-error-on-vs-2017-image-suddenly.
2017-08-21 17:31:14 +02:00
Niels Lohmann ba5d37ba4b 👷 added Clang 5.0 (see https://docs.travis-ci.com/user/languages/cpp/#clang) 2017-08-21 17:27:35 +02:00
Niels Lohmann 64ef100ebf Revert "💥 changed iterators to andom_access_iterator #593"
This reverts commit c77a0be5f3.
2017-08-20 20:44:44 +02:00
Niels Lohmann 8acaf5bdbc 🚨 fixing two compiler warnings 2017-08-20 19:31:07 +02:00
Niels Lohmann c77a0be5f3 💥 changed iterators to andom_access_iterator #593
This commit changes the iterator category to andom_access_iterator and allows offsets and subscript operators for object iterators.
2017-08-16 21:35:22 +02:00
Niels Lohmann aba8b58492 🔨 approach to un-break the changes for #462 2017-08-16 20:11:05 +02:00
Niels Lohmann 22b59693f1 💥 CBOR/MessagePack input must end with EOF #505
The CBOR and MessagePack parsers now expect the input to be read until the end. Unless the new parameter "strict" is set to false (it is true by default), an exception is raised if the parser ends prematurely. This is a breaking change as the parsers ignored unread input so far.

Furthermore, the offset/startIndex paramter introduced in #462 was removed as this behavior can be mimicked with an iterator range. For instance, instead of calling "from_cbor(vec, 5);", you can write "from_cbor({vec.begin()+5, vec.end()});".
2017-08-16 14:48:23 +02:00
Niels Lohmann 1f31a5b808 ⬆️ Catch v1.9.7 2017-08-16 10:23:39 +02:00
Niels Lohmann f5a53de845 👷 running sanitizer job in parallel 2017-08-16 09:21:20 +02:00
Niels Lohmann 21726d8d8f 👷 run sanitizer after tests 2017-08-16 08:11:02 +02:00
Niels Lohmann df572aca79 👷 set sanitizer to clang4 2017-08-16 07:42:57 +02:00
Niels Lohmann 4391bf5615 Merge branch 'feature/update' into develop 2017-08-16 07:39:30 +02:00
Niels Lohmann 1e360bb32b 🔨 preparation for #505
Added a parameter to control whether parsing CBOR and MessagePack must completely consume the input.
2017-08-16 07:39:11 +02:00
Niels Lohmann 002410410f Merge branch 'develop' into feature/update 2017-08-15 21:42:58 +02:00
Niels Lohmann 72afe53fa0 📝 updated documentation for update() function #661 2017-08-15 21:42:50 +02:00
Niels Lohmann 76123fab76 📝 added note wrt. #667 2017-08-15 20:49:18 +02:00
Niels Lohmann fdff42bc3d 👷 forgot to install Cmake on OSX 2017-08-15 20:30:01 +02:00
Niels Lohmann 039e2f03bc Merge branch 'develop' into feature/update 2017-08-15 19:54:22 +02:00
Niels Lohmann 7f4722a75d Merge branch 'feature/travis_clang' into develop 2017-08-15 19:52:47 +02:00
Niels Lohmann 08805f7f14 🔨 cleanup 2017-08-13 20:57:27 +02:00
Niels Lohmann 988077e046 Merge branch 'develop' into feature/travis_clang 2017-08-13 20:27:27 +02:00
Niels Lohmann 7d19aed567 🔨 cleanup 2017-08-13 19:02:58 +02:00
Niels Lohmann 569c00eb18 👷 changed c++17 to c++1z 2017-08-10 23:41:12 +02:00
Niels Lohmann 6151b056eb 🔨 cleanup 2017-08-10 23:40:30 +02:00
Niels Lohmann bade3b3e6c 👷 cleanup 2017-08-10 21:17:40 +02:00
Niels Lohmann 76b195d7d1 👷 fix for coverity + clang-5.0 2017-08-10 20:54:59 +02:00
Niels Lohmann cd34358e7c 👷 removing clang from source 2017-08-10 20:37:23 +02:00
Niels Lohmann 5eb9f5fd4f 👷 clang-3.4 2017-08-10 20:31:59 +02:00
Niels Lohmann f49356e703 👷 clang-3.4 2017-08-10 20:26:49 +02:00
Niels Lohmann e0f8eb1710 👷 clang-4.0 2017-08-10 20:21:41 +02:00
Niels Lohmann 6dc89e47fc 👷 clang-3.9 2017-08-10 20:16:35 +02:00
Niels Lohmann 8de710bbe7 👷 added source for gcc 2017-08-10 20:12:27 +02:00
Niels Lohmann 195d773bc5 👷 added gcc 2017-08-10 20:09:39 +02:00
Niels Lohmann e7f2d2646a 👷 removed gcc 2017-08-10 20:06:47 +02:00
Niels Lohmann 6b20f6d1ef 👷 clang-3.8 2017-08-10 20:04:36 +02:00
Niels Lohmann 82cd8c8d02 👷 another try 2017-08-10 19:59:00 +02:00
Niels Lohmann f256587c4f 👷 clang-3.4 2017-08-10 19:56:09 +02:00
Niels Lohmann c06b5c5c10 👷 clang-3.5 2017-08-10 19:50:36 +02:00
Niels Lohmann 3283352db3 👷 using clang++ 2017-08-10 19:45:33 +02:00
Niels Lohmann c20dd7522f 👷 another try 2017-08-10 19:40:09 +02:00
Niels Lohmann 94dfecd487 👷 removed g++ 2017-08-10 19:31:43 +02:00
Niels Lohmann 8963aae57d 👷 clang-3.6 2017-08-10 19:24:36 +02:00
Niels Lohmann 5aceb0e029 👷 clang-3.6 2017-08-10 19:23:55 +02:00
Niels Lohmann e7a7e4f81f 👷 fixed compiler 2017-08-10 19:18:45 +02:00
Niels Lohmann e333562633 👷 different source 2017-08-10 19:15:16 +02:00
Niels Lohmann eb6de822bb 👷 clang-3.7 2017-08-10 19:12:04 +02:00
Niels Lohmann c1642affaa 👷 clang-3.8 2017-08-10 19:03:35 +02:00
Niels Lohmann a46afd4008 Merge pull request #679 from traits/patch-1
Digraph warning
2017-08-10 11:39:13 +02:00
traits 54c67dcfec Update json.hpp 2017-08-10 09:05:00 +02:00
Niels Lohmann 99ea12f304 📝 acknowledgements for #674, #678, #682, #685, and #686 2017-08-10 06:50:34 +02:00
Niels Lohmann d26b3f1fe5 Merge pull request #686 from WebProdPP/patch-1
Update json.hpp
2017-08-10 06:44:59 +02:00
Niels Lohmann 345846b514 Merge pull request #685 from daixtrose/patch-1
Remove duplicate word
2017-08-09 15:32:33 +02:00
WebProdPP c9509ccf97 Update json.hpp
mistake
2017-08-09 16:13:43 +03:00
Markus Werle 86b3d06a93 remove duplicate word
s/to to/to/
2017-08-09 11:56:48 +02:00
Niels Lohmann 6e5b895f87 Merge pull request #682 from kbthomp1/fix-intel-osx
To fix compilation issue for intel OSX compiler
2017-08-09 10:16:03 +02:00
Kyle Thompson 4b55f0ebd6 To fix compilation issue for intel OSX compiler
o To prevent the compilation issue on OSX with the intel compiler suite.  The
error was found with icpc version 15.0.3.187 where the "__clang_version__" was
not defined correctly, while "__clang__" was.
2017-08-08 18:43:03 -04:00
Niels Lohmann c90bf5e0f1 👷 removed failing builders 2017-08-08 21:26:15 +02:00
Niels Lohmann dd008545d1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-08-08 19:15:49 +02:00
Niels Lohmann 054b0250be 👷 trying to install g++ to make clang work 2017-08-08 19:14:22 +02:00
traits ab44a50d98 Digraph warning
The original version can trigger a digraph-related warning in VS2015. Is this namespace construct a typo or something deliberate?
2017-08-07 14:23:48 +02:00
Niels Lohmann b32a6b8c75 Merge pull request #678 from DmitryKuk/develop
massage -> message
2017-08-05 13:42:43 +02:00
DmitryKuk 19437c15de massage -> message 2017-08-05 10:43:08 +03:00
Niels Lohmann e523312fa2 improved test coverage 2017-08-03 17:47:42 +02:00
Niels Lohmann d2c3592908 added test cases for update #661 2017-08-02 22:44:58 +02:00
Niels Lohmann d1e13d5128 🎉 first draft for #661 2017-08-02 22:12:41 +02:00
Niels Lohmann 0ea0d7d860 Merge pull request #674 from wincent/patch-1
Fix "not constraint" grammar in docs
2017-08-01 20:21:04 +02:00
Niels Lohmann efdfd3aa5b replaced by-value call #673 2017-08-01 19:37:25 +02:00
Greg Hurrell 391303521a Fix "not constraint" grammar in docs 2017-08-01 08:56:28 -07:00
Niels Lohmann 76ecb2bd60 Merge pull request #671 from dan-42/develop
Add documentation for integration with CMake and hunter
2017-08-01 07:15:55 +02:00
dan-42 db0b9732d4 DOC: add sort mentioning about support in hunter 2017-07-31 23:20:37 +02:00
Niels Lohmann e60002a1b3 🔨 fixed GCC warnings in #663
https://github.com/nlohmann/json/pull/663#issuecomment-318931884
2017-07-31 23:17:14 +02:00
dan-42 966989a3f5 CONFIG: pin cmake to enable only C++ 2017-07-31 09:49:26 +02:00
Niels Lohmann 850d856aae 🔨 cleanup after #663 2017-07-30 20:30:05 +02:00
Niels Lohmann 3d67ec40a6 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-07-30 20:01:35 +02:00
Niels Lohmann 85c768084b 🔨 using emplace 2017-07-30 20:01:31 +02:00
Niels Lohmann 67fb517ccd Merge pull request #669 from dan-42/change_installed_cmake_include_path
REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse
2017-07-30 20:01:03 +02:00
Niels Lohmann 80e95844f6 Merge pull request #663 from himikof/move-construction
Support moving from rvalues in std::initializer_list
2017-07-30 20:00:46 +02:00
Niels Lohmann aad55219f8 Merge branch 'develop' into move-construction 2017-07-30 19:49:24 +02:00
Niels Lohmann 96dd4ffa19 🔨 simplified a call 2017-07-30 18:30:34 +02:00
Niels Lohmann 7737a29518 🔨 small parser performance improvements
- replaced list of pairs by flat list in next_byte_in_range
- implemented early exit in case of parse errors
- reused memory for object keys
- direct calls to embedded objects/arrays for insertions
2017-07-30 13:25:36 +02:00
dan-42 f434942371 REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse
The rewrite uses more cmake build-in automatisms and build-in generates
variables to allow better generic reuse.
* cmake  files are installed to
``` <install_prefix>/lib/cmake/nlohmann_json/ ``` for best support on
most systems
* include path is set to ``` include ```  for usage as ``` #include
<nlohmann/json.hpp> ```
2017-07-29 11:59:09 +02:00
Niels Lohmann c819a2d732 🔨 refactored some scanner internals 2017-07-28 19:18:50 +02:00
Niels Lohmann 5851daa576 binary formats can be stored in std::string, std::ofstreams or std::ostringstream #477 2017-07-28 00:21:55 +02:00
Niels Lohmann c136b6f200 Merge pull request #666 from effolkronium/develop
enable_testing only if the JSON_BuildTests is ON
2017-07-27 20:48:56 +02:00
Niels Lohmann 7d51214045 implemented exception-free parser #458 #582
You can now pass a boolean "allow_exceptions" to the parse functions. If it is false, no exceptions are thrown in case of a parse error. Instead, parsing is stopped at the first error and a JSON value of type "discarded" (check with is_discarded()) is returned.
2017-07-27 20:33:11 +02:00
Ilya Polishchuk a27dd3a6f6 enable_testing only if JSON_BuildTests is ON 2017-07-27 17:50:24 +03:00
Niels Lohmann 669ebf51bc 🔨 fixed an error in MSVC 2017-07-27 06:04:35 +02:00
Niels Lohmann 3d589fd032 🔨 fixed compilation error 2017-07-26 23:59:56 +02:00
Niels Lohmann e6aa700360 🔨 cleanup 2017-07-26 23:44:55 +02:00
Nikita Ofitserov 93bb71232d Move from rvalues eagerly to work around MSVC problem
On MSVC compiler, temporaries that are constructed during a
list initialization, are sometimes destroyed even before calling
the initializing constructor, instead of at the end of the
containing full-expression. This is clearly non-conforming to
[class.temporary].
As the impact of this bug is silently producing incorrect
JSON values, move eagerly from rvalues to be safe.

See https://stackoverflow.com/questions/24586411
2017-07-25 12:17:32 +03:00
Nikita Ofitserov 897879bccb Make detail::json_ref do less work by deferring moves/copies 2017-07-24 12:29:06 +03:00
Nikita Ofitserov 0f4978e503 Fix an actually invalid test
C++ overload resolution/list initialization rules are hard.
2017-07-24 01:08:33 +03:00
Niels Lohmann 4414f94cd5 🔨 using input/output adapters for CBOR and MessagePack
- You can now pass a reference to a vector to the to_cbor and to_msgpack functions. The output will be written (appended) to the vector. #476

- You can now pass an output stream with uint8_t character type to the to_cbor and to_msgpack functions. #477

- You can now read from uint8_t */size in the to_cbor and to_msgpack functions. An input adapter will be created from this pair, so you need to use braces. #478
2017-07-23 23:02:24 +02:00
Nikita Ofitserov f5cae64e52 Update tests while fixing possible UB
std::initializer_list does not own the temporaries created in
its initialization. Therefore, storing it in an independent
stack variable is unsafe.
2017-07-23 23:59:34 +03:00
Nikita Ofitserov 09cda57309 Support moving from rvalues in an std::initializer_list
This commit works around an issue in std::initializer_list design.
By using a detail::json_ref proxy with a mutable value inside,
rvalue-ness of an input to list initializer is remembered and
used later to move from the proxy instead of copying.
2017-07-23 23:57:17 +03:00
Nikita Ofitserov cf3ca3b78c Optimize json construction from rvalue string_t/array_t/object_t 2017-07-23 23:50:59 +03:00
Nikita Ofitserov 7b3cbfff23 Add some tests for std::move from std::initializer_list 2017-07-23 23:47:15 +03:00
Niels Lohmann 9b1c058810 🔨 reorganized interfaces for parse/accept functions #623
We now rely on implicit conversions to an input_adapter object in the parse/accept functions.
2017-07-23 18:11:34 +02:00
Niels Lohmann 18e0430bfe 🔨 adding destroy function to discard values 2017-07-22 22:57:22 +02:00
Niels Lohmann 5b5f0090a1 🔨 trying to fix the sanitizer error
Travis found an error with Clang 3.8's sanitizers, see https://travis-ci.org/nlohmann/json/jobs/256366699. Unfortunately, I cannot reproduce this error with clang version 6.0.0 (trunk 308825) locally. However, this seems to be an issue, because so far, we did not reset a value after moving from it.
2017-07-22 16:41:42 +02:00
Niels Lohmann d53ef95067 🔨 fixed some warnings 2017-07-22 15:33:31 +02:00
Niels Lohmann c7a69ae03e started working on parser with provded result reference #418
Internally, the parser now writes its result into a JSON value provided as a reference. To be usable, the public interfaces need to be extended.
2017-07-22 15:18:38 +02:00
Niels Lohmann f513c46749 🔨 further cleanup 2017-07-22 13:35:04 +02:00
Niels Lohmann 024fec8a9b 🔨 more cleanup using clang-tidy 2017-07-21 18:26:07 +02:00
Niels Lohmann a09193e967 🔨 cleanup
- Replaced codepoint calculation by bit operations.
- Fixed several clang-tidy warnings.
2017-07-20 23:01:16 +02:00
Niels Lohmann 21d23982ca 🐛 fix for #656
A complete rewrite of the string escape function. It now provides codepoint-to-\uxxxx escaping. Invalid UTF-8 byte sequences are not escaped, but copied as-is. I haven’t spent much time optimizing the code - but the library now agrees with Python on every single Unicode character’s escaping (see file test/data/json_nlohmann_tests/all_unicode_ascii.json).

Other minor changes: replaced "size_t" by "std::size_t"
2017-07-17 07:53:02 +02:00
Niels Lohmann 8a9133c6b2 Merge pull request #652 from olegendo/develop
Rename BuildTests to JSON_BuildTests
2017-07-15 11:39:27 +02:00
Niels Lohmann f1fabd1ba2 📄 added code of conduct
added Contributor Covenant Code of Conduct
2017-07-13 19:16:41 +02:00
Niels Lohmann dad4916f9e Merge pull request #654 from ryanjmulder/develop
add ensure_ascii parameter to dump. #330
2017-07-12 07:58:45 +02:00
Ryan Mulder 486f3a2d16 restore necessary comman in documentation of dump 2017-07-11 14:18:02 -04:00
Ryan Mulder 40461c6c55 update comment on dump to not indicate that ensure_ascii is true by default 2017-07-11 13:59:07 -04:00
Ryan Mulder 71597be294 add ensure_ascii parameter to dump. #330 2017-07-11 13:48:08 -04:00
Oleg Endo cd800522e4 Rename BuildTests to JSON_BuildTests
This avoids potential conflicts with other libraries when the library is
built from source and included in a bigger cmake build.
2017-07-11 22:57:49 +09:00
Niels Lohmann 7dee868a42 Merge pull request #643 from theodelrieu/refacto/split_basic_json
Refacto/split basic json
2017-07-09 23:12:35 +02:00
Théo DELRIEU 8585d35c92 move serializer outside of basic_json 2017-07-09 21:30:34 +02:00
Théo DELRIEU acff23efb2 move binary_{reader,writer} outside of basic_json 2017-07-09 21:30:33 +02:00
Théo DELRIEU bb752fd30c move json_reverse_iterator outside of basic_json 2017-07-09 21:30:33 +02:00
Théo DELRIEU 0ba98b6fe0 move internal_iterator/iter_impl/iteration_proxy outside of basic_json 2017-07-09 21:30:31 +02:00
Théo DELRIEU 00d6e27194 move primitive_iterator outside of basic_json 2017-07-09 21:22:16 +02:00
Théo DELRIEU 8e681d1e57 move lexer/parser outside of basic_json 2017-07-09 21:22:15 +02:00
Théo DELRIEU 15625ca4a7 move input adapters outside of basic_json 2017-07-09 21:21:12 +02:00
Théo DELRIEU a332142194 move json_pointer outside of basic_json 2017-07-09 21:21:09 +02:00
Théo DELRIEU fe086d7432 forward declare basic_json, add two macros
Those macros are used to reduce template argument boilerplate
2017-07-09 16:16:42 +02:00
Niels Lohmann d3496347fc 👷 removing Clang 3.9 and 4.0
These versions are still not working properly: https://travis-ci.org/nlohmann/json/jobs/251675281
2017-07-09 12:19:14 +02:00
Niels Lohmann 504012a3db 📝 cleanup after #650
As <iostream> is not included in json.hpp any more, all code examples need to include <iostream> now.
2017-07-09 11:51:38 +02:00
Niels Lohmann a0e0579374 Merge pull request #650 from olegendo/develop
Don't include <iostream>, use std::make_shared
2017-07-09 11:12:46 +02:00
Niels Lohmann 1b2fabe802 👷 adding two recent Clang versions
Maybe the simple approach is working now - at least it is in https://github.com/taocpp/PEGTL/blob/master/.travis.yml
2017-07-09 11:10:18 +02:00
Oleg Endo e3bb156f82 fix typo 2017-07-09 15:20:28 +09:00
Oleg Endo b753cb6ee7 use std::make_shared 2017-07-09 15:19:08 +09:00
Oleg Endo f0ca96d462 include <iosfwd> instead of <iostream>
avoid bloat caused by <iostream> and std::cout and friends in apps where
iostream are not used.
2017-07-09 15:04:49 +09:00
Niels Lohmann f1c543cb7b 👷 added GCC7 2017-07-08 22:59:19 +02:00
Niels Lohmann 7b05e1a687 🔨 improved performance in dump for deeply nested values 2017-07-08 22:59:04 +02:00
Niels Lohmann f697fec522 📝 fixed documentation
There was an issue in the documentation example before. Unfortunately, I did not recreate the example outputs.
2017-07-08 22:16:45 +02:00
Niels Lohmann 87bccbc335 🔨 removed exception parse_error.111
It makes no sense to have this special exception. Instead of throwing when an input adapter is created, it is better to detect a parse error in later usage when an EOF is "read" unexpectedly.
2017-07-08 21:35:13 +02:00
Niels Lohmann b38ecb5ca9 🔨 simplified binary write
Also added some comments and improved the documentation.
2017-07-08 20:31:13 +02:00
Niels Lohmann b3ac36db93 🔨 excluded uncovered lines
These breaks were just added to silence a GCC warning - the GCC is right about warning as it cannot know that the expect function will not return in these two scenarios.
2017-07-08 18:34:08 +02:00
Niels Lohmann e67df7c385 Merge branch 'feature/undo_171' into develop 2017-07-08 16:34:00 +02:00
Niels Lohmann 552622343e 📝 fixed typos 2017-07-08 16:18:27 +02:00
Niels Lohmann 566f6dcf30 🔥 removing usused functions #645
It seems these functions are not required any more. The code was added in commit 7e32457 to fix issue #171. There are still regression tests for #171, so when this commit passes the CI, the functions may be removed for good.
2017-07-08 13:33:13 +02:00
Niels Lohmann 6f12749ef6 📝 added version string for Xcode 9 2017-07-08 12:55:05 +02:00
Niels Lohmann ac42333749 ⬆️ Catch v1.9.6 2017-07-08 12:11:45 +02:00
Niels Lohmann 015c88783e 🔨 fixed a pedantic warning 2017-07-08 12:03:12 +02:00
Niels Lohmann df2feabb72 👷 added Xcode 9 beta
See https://twitter.com/travisci/status/880550780368855040
2017-07-08 11:57:09 +02:00
Niels Lohmann 63ecbfd36b re-added test
I have no idea why this test has been removed in the first place.
2017-07-07 23:38:04 +02:00
Niels Lohmann 07b78c993c 🐛 fixed undefined behavior bug
When an empty vector was passed to the parse function, an empty iterator range was used to construct an input iterator. Unfortunately, we then cannot use the start iterator to derive a pointer from.

Found with Xcode's undefined behavior sanitizer.
2017-07-07 23:37:16 +02:00
Niels Lohmann 8b123107c0 🔨 fixed some pedantic GCC warnings 2017-07-07 22:41:22 +02:00
Niels Lohmann 32065c8045 📝 fix for #639
Removed deprecated documentation of the comparison operator.
2017-07-07 21:16:33 +02:00
Niels Lohmann e99b783def 🔨 simplifying scanner 2017-06-22 16:40:15 +02:00
Niels Lohmann 3dc5d95422 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-06-21 18:55:28 +02:00
Niels Lohmann b9a8425cc8 📝 cleanup after #629 and #630 2017-06-21 18:55:25 +02:00
Niels Lohmann 5ee651c387 Merge pull request #630 from Chocobo1/doc_neq
fix typo in operator__notequal example
2017-06-21 18:54:18 +02:00
Niels Lohmann dad6051f37 Merge pull request #629 from Chocobo1/c4819
Fix MSVC warning C4819
2017-06-21 18:54:03 +02:00
Niels Lohmann 4b5433578a added progress output for Unicode tests
Travis aborts tests if they do not produce output for 10 minutes. This commit shall fix this.
2017-06-21 18:50:11 +02:00
Chocobo1 0395f3fdfb fix typo 2017-06-21 21:41:34 +08:00
Chocobo1 66ffac9e8a Fix MSVC warning C4819
Replace unicode whitespaces by ASCII whitespace 0x20
2017-06-21 16:17:10 +08:00
Niels Lohmann 6f3bebff5c 🔨 removed unexpect function 2017-06-21 07:26:50 +02:00
Niels Lohmann 2fd214c14b 🔨 adjusted pedantic flags 2017-06-20 23:05:37 +02:00
Niels Lohmann e7695306f1 🔨 fixed a warning 2017-06-20 22:58:02 +02:00
Niels Lohmann 84f2e64a7c improved coverage 2017-06-20 22:35:31 +02:00
Niels Lohmann 9add24ff10 🔨 fixed a warning 2017-06-20 22:20:41 +02:00
Niels Lohmann 2f007ca092 improved coverage 2017-06-20 22:03:36 +02:00
Niels Lohmann a5c27ede32 🔨 fixed a warning 2017-06-20 21:39:36 +02:00
Niels Lohmann 7c2a187258 improved test coverage 2017-06-20 21:09:26 +02:00
Niels Lohmann e191dd833f 🔨 fixed warning about pointer members 2017-06-20 21:09:05 +02:00
Niels Lohmann 82b95ca664 🔨 simplified error handling in parser 2017-06-20 20:14:18 +02:00
Niels Lohmann f2cdb3d594 ⬆️ Catch v1.9.5 2017-06-20 20:13:56 +02:00
Niels Lohmann c2044205ef 📝 updated used compilers 2017-06-20 16:12:14 +02:00
Niels Lohmann c2db4a118d 👷 update Travis to use Ubuntu Trusty 14.04 images 2017-06-19 21:51:24 +02:00
Niels Lohmann 70b7455a13 🔨 minor change 2017-06-19 21:50:36 +02:00
Niels Lohmann 4e6f548c0b Merge pull request #624 from theodelrieu/feature/pair_tuple_conversions
add pair/tuple conversions
2017-06-19 17:31:10 +02:00
Théo DELRIEU 08d781058c add from_json support for std::array 2017-06-19 12:03:38 +02:00
Théo DELRIEU 6e4910d5c5 add pair/tuple conversions 2017-06-19 10:16:37 +02:00
Niels Lohmann 112a6f4e53 🔨 replaced lexer's error message by const char* 2017-06-18 13:03:14 +02:00
Niels Lohmann 747f7d36d1 Merge branch 'develop' of https://github.com/nlohmann/json into develop 2017-06-18 00:00:36 +02:00
Niels Lohmann b79a1a2678 📝 update after #626 2017-06-18 00:00:31 +02:00
Niels Lohmann 7b97100ffd Merge pull request #626 from koemeet/bugfix/vs2017-min-macro-fix
[BugFix] Add parentheses around std::min
2017-06-17 23:58:13 +02:00
Steffen Brem 04a1666ef2 Add parentheses around std::min so it bypasses the macro introduced by windows.h. 2017-06-17 22:01:18 +02:00
Niels Lohmann 1fbb82de89 🔨 using std::array to buffer input 2017-06-17 20:47:53 +02:00
Niels Lohmann 889006f006 regression test for #600 2017-06-17 13:37:04 +02:00
Niels Lohmann e1ca484bc1 📝 added note about Conan #566 2017-06-17 11:20:09 +02:00
Niels Lohmann b27d2adcbe accept functions to check if input is valid JSON #458 2017-06-16 19:23:55 +02:00
Niels Lohmann d415293d41 Merge pull request #615 from theodelrieu/develop
remove std::pair support
2017-06-16 18:16:20 +02:00
Théo DELRIEU c98364834f remove std::pair support 2017-06-13 11:11:29 +02:00
Niels Lohmann fd4a0ecabc Merge branch 'feature/ifstream' into develop 2017-06-13 08:41:14 +02:00
Niels Lohmann 88dc7c11fa 🔨 fixed a warning 2017-06-12 19:58:44 +02:00
Niels Lohmann afb959a083 🔨 removed nonportable code 2017-06-12 19:02:08 +02:00
Niels Lohmann ac793e957f 🔨 trying to fix #367
Code from https://stackoverflow.com/a/44503794/266378 which is hopefully working with MSVC.
2017-06-12 18:58:58 +02:00
Niels Lohmann 5fa5c17bc6 ✏️ cleanup after #595 2017-06-10 18:29:16 +02:00
Niels Lohmann 6caad48e44 Merge pull request #595 from HenryRLee/iterator_arithmetic
Issue #593 Fix the arithmetic operators in the iterator and reverse iterator
2017-06-10 18:26:48 +02:00
HenryLee e12c2ee6a8 Merge branch 'develop' into iterator_arithmetic 2017-06-09 20:47:42 +10:00
Niels Lohmann 52f934cbbf Merge pull request #609 from theodelrieu/develop
Add pair support, fix CompatibleObject conversions (fixes #600)
2017-06-07 16:38:23 +02:00
Théo DELRIEU cea39dfaa8 fix #600
Instead of calling CompatibleObjectType iterator-range constructor,
first convert json::value_type to CompatibleObjectType::value_type
2017-06-07 10:24:59 +02:00
HenryLee 6661ec755b Merge branch 'develop' into iterator_arithmetic 2017-06-07 18:01:46 +10:00
HenryLee 0f065edff6 Revert a change in reverse iterator to pass the test cases 2017-06-07 18:01:01 +10:00
Niels Lohmann 92ef19696a ✏️ cleanup after #598 2017-06-06 20:48:11 +02:00
Niels Lohmann bfdf0d1ce6 Merge pull request #598 from HenryRLee/issue550
#550 Fix iterator related compiling issues for Intel icc
2017-06-06 20:41:42 +02:00
Théo DELRIEU 85de93ba93 add std::pair<CompatibleStringType, T> support 2017-06-06 13:56:16 +02:00
HenryLee c98169d0d5 Revert "Change iterator category to random access"
This reverts commit c4ab8f827e.
2017-06-05 21:59:17 +10:00
HenryLee fb91aa81da Merge branch 'develop' into iterator_arithmetic 2017-06-05 20:24:21 +10:00
HenryLee 2ba554e442 Merge branch 'develop' into issue550 2017-06-05 20:24:08 +10:00
Niels Lohmann 1a9d76679a 🐛 fixed the issue with GCC7 #590 2017-06-04 18:40:32 +02:00
Niels Lohmann d19c5ced4b 🐛 skipping BOM for iterators #602
I totally forgot about byte order marks in this scenario.
2017-06-02 12:38:32 +02:00
Niels Lohmann c043ba6978 🔥 removed failing test #529 2017-06-01 07:32:39 +02:00
HenryLee f2e1643039 Add test cases for iterator to const iterator assignment 2017-05-31 00:50:40 +10:00
HenryLee 2d5f0c0549 Redefine the converting assignment in iterator 2017-05-31 00:50:14 +10:00
HenryLee c09a4cbbd7 Add test cases for iterator to const iterator conversion 2017-05-31 00:31:16 +10:00
HenryLee 0a51fb22ed Fix indentation 2017-05-30 23:37:24 +10:00
HenryLee 881cd3f420 Remove the iter_impl<const basic_json> copy constructor and copy assignment 2017-05-30 20:57:22 +10:00
HenryLee 790e7ca9e9 Add struct keyword in front of internal_iterator 2017-05-30 20:27:05 +10:00
HenryLee ce39330ff8 Add converting constructors for iterator 2017-05-30 20:23:25 +10:00
HenryLee c4ab8f827e Change iterator category to random access 2017-05-30 19:44:55 +10:00
HenryLee daea213b44 Use static cast in the implementation of the operators of reverse iterator 2017-05-29 23:56:21 +10:00
HenryLee 0c2ed00ebe Add missing test cases for n + it arithmetic in iterators 2017-05-29 22:39:27 +10:00
HenryLee 5b245dae06 Comment out the exception message check in operator[] of reverse iterator 2017-05-29 22:19:10 +10:00
HenryLee e42db27d6d Fix the indentation from the latest commit 2017-05-29 20:02:58 +10:00
HenryLee 3aef1a582e Change the definition of the operator override of reverse iterator to using the result of the base class directly 2017-05-29 19:45:34 +10:00
HenryLee a3bf0131c4 Fix some more reverse iterator arithmetic test codes 2017-05-29 19:43:45 +10:00
HenryLee adc73d6d5f Fix the arithmetic mistakes in reverse iterator 2017-05-29 18:52:53 +10:00
HenryLee ed62129f8e Override n + iterator operator in the iterator 2017-05-27 13:44:14 +10:00
Niels Lohmann 52adf3fd5b 🔨 fixed compilation 2017-05-22 22:59:57 +02:00
Niels Lohmann 9a576fe1d9 added test for #367 2017-05-22 22:49:39 +02:00
Niels Lohmann c7bd01edf2 🔨 trying something #367 2017-05-22 17:06:46 +02:00
Niels Lohmann 9e507dfad5 tests and fix for #367
operator>> now works as expected.
2017-05-21 16:36:51 +02:00
Niels Lohmann 16b63d3197 🔨 working toward #367 2017-05-20 12:44:13 +02:00
Niels Lohmann 8a35fdd8f5 🔨 overworked accept() function
Fixed to make sure no token is "overlooked".
2017-05-20 12:24:13 +02:00
Niels Lohmann 9ddc69f3a9 🐛 adjusting fix for future versions #586 2017-05-20 10:49:06 +02:00
Niels Lohmann 99cb095e89 🐛 fix for #586
Also added a Travis builder with -std=c++1z
2017-05-20 10:34:49 +02:00
Niels Lohmann 0f4131d138 Merge pull request #583 from zhaohuaxishi/doxygen_error
fix doxygen error of basic_json::get()
2017-05-15 21:09:43 +02:00
Niels Lohmann 0c3ffe12cd reverting first/second experiment #350 2017-05-15 21:07:58 +02:00
郭荣飞 b8dff3bc16 remove the redundant @ref command 2017-05-14 07:59:07 +08:00
Niels Lohmann 723c875604 💬 replaced "backspace" with "backslash" #509 2017-05-13 19:56:38 +02:00
郭荣飞 dfa371c436 fix doxygen error of basic_json::get() 2017-05-13 23:13:04 +08:00
Niels Lohmann 9b764ee5d6 🏁 fix for #581 2017-05-13 12:27:37 +02:00
Niels Lohmann 978255da8c 📝 updated contribution guidelines 2017-05-13 11:57:15 +02:00
Niels Lohmann 8b88e1b266 Merge pull request #579 from Type1J/develop_feature_first_second
Fixing assignement for iterator wrapper second, and adding unit test
2017-05-13 11:37:57 +02:00
Jay Sistar b78457b792 Making comparison operators const. 2017-05-11 13:22:47 -04:00
Jay Sistar 00d841bfda Adding equal and not equal operators to proxys. 2017-05-11 14:51:06 +00:00
Jay Sistar d6c78dacd8 Fixing assignement for iterator wrapper second, and adding unit test 2017-05-10 17:53:27 +00:00
Niels Lohmann 5beea35443 Merge pull request #578 from Type1J/develop_feature_first_second
Adding first and second properties to iteration_proxy_internal
2017-05-10 17:25:54 +02:00
Niels Lohmann 15ef9b8a35 Merge pull request #576 from Type1J/develop
Adding support for Meson.
2017-05-10 16:32:14 +02:00
Jay Sistar 6a656ed375 Adding first and second properties to iteration_proxy_internal 2017-05-10 13:20:52 +00:00
Niels Lohmann 2afbd33472 🔨 working on #367
Test cases succeed as expected, but the example in #367 is not fully
realized yet.
2017-05-10 12:06:24 +02:00
Jay Sistar 87744fd594 Missed one. 2017-05-09 02:04:02 +00:00
Jay Sistar 0719287e44 Reducing chatter about Meson. 2017-05-09 02:01:55 +00:00
Jay Sistar 31fe2f5825 Adding support for Meson. 2017-05-08 13:35:00 +00:00
Niels Lohmann 962da00171 implemented an indentation character #520
An optional parameter for dump() allows to set the character to use for
indentation (default: space). In case a JSON value is serialized to an
output stream, its fill character is used (and can be set with
std::setfill).
2017-05-07 19:27:40 +02:00
Niels Lohmann fba1bcdd0b 🐛 fixing #575
I forgot to consider the offset.
2017-05-07 13:41:48 +02:00
Niels Lohmann 56ac7908f1 Merge branch 'feature/manual_lexer' into develop 2017-05-05 18:27:56 +02:00
Niels Lohmann dbcb032f22 Merge branch 'develop' into feature/manual_lexer 2017-05-05 16:48:47 +02:00
Niels Lohmann ecf895f2d1 📝 mentioned value function on main doc page #570 2017-05-05 16:42:22 +02:00
Niels Lohmann 19d2dec8b6 📝 added badge from isitmaintained.com 2017-05-03 22:49:21 +02:00
Niels Lohmann 8b9f51179e started working on #458
a simple acceptor function
2017-04-24 17:46:21 +02:00
Niels Lohmann cfc2e8391c 🔨 removed too long running tests 2017-04-24 15:07:43 +02:00
Niels Lohmann 6d2c0a7928 added more Unicode test cases 2017-04-23 22:54:21 +02:00
Niels Lohmann c42273d2a0 📝 fixed documentation #565
The documentation mismatched the actual code.
2017-04-23 21:46:30 +02:00
Niels Lohmann 2df8f12c09 🏁 another fix for MSVC #464
needed for VS2015.3 with /std:c++latest
2017-04-23 20:51:29 +02:00
Niels Lohmann 734297ff45 🔨 cleanup 2017-04-23 20:32:05 +02:00
Niels Lohmann 01e05d89e9 🔨 fixed a compiler warning
Default arguments are forbidden in lambdas.
2017-04-23 18:40:17 +02:00
Niels Lohmann b686cc6ad9 🔨 removed #ifdefs 2017-04-23 18:34:14 +02:00
Niels Lohmann 5febd04a26 🐛 fixed test suite 2017-04-23 18:22:35 +02:00
Niels Lohmann 4aedae400e added exhaustive UTF-8 tests
Creates all well-formed sequences of bytes up to length 4. Furthermore,
creates ill-formed sequences by removing required trailing bytes or
changing bytes. As the tests can take a lot of time, preprocessor
symbols are introduced.
2017-04-23 15:12:50 +02:00
Niels Lohmann e24df7eca9 📝 improved documentation 2017-04-23 15:10:40 +02:00
Niels Lohmann 2a21146160 Merge branch 'develop' into feature/manual_lexer 2017-04-22 11:35:58 +02:00
Niels Lohmann 4b316ec528 Merge branch 'feature/insert' into develop 2017-04-22 09:58:37 +02:00
Niels Lohmann 9b32f72584 📝 fixed examples for Wandbox
As I learned in https://github.com/melpon/wandbox/issues/209, this
library is already installed at Wandbox, so we need to adjust the
examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
2017-04-21 22:07:07 +02:00
Niels Lohmann db9bf953f3 🔨 improved diagnostic output 2017-04-15 10:40:10 +02:00
Niels Lohmann 717106eced 🔨 templated output_adapter and used in class serializer 2017-04-14 19:49:05 +02:00
Niels Lohmann aea47422a2 📝 updated links and output 2017-04-14 18:13:01 +02:00
Niels Lohmann 6b6e554067 🐛 added missing header
std::setw needs the iomanip header (at least with GCC).
2017-04-14 17:37:28 +02:00
Niels Lohmann 951d0920fc 🐛 fixed README example
The example with the size() operator is bad: using operator[] already
changes the size of the object. The fix makes it clearer.
2017-04-14 17:36:45 +02:00
Niels Lohmann e2f6cf7f46 🔥 removed .test files
These files were never meant to be versioned.
2017-04-14 17:35:31 +02:00
Niels Lohmann 2d2b98a50a Merge branch 'develop' into feature/manual_lexer 2017-04-12 18:07:25 +02:00
Niels Lohmann d4469233ac Merge branch 'develop' into feature/insert 2017-04-12 18:01:06 +02:00
Niels Lohmann 42b4cdd4d0 👷 Travis is very picky 2017-04-11 22:13:26 +02:00
Niels Lohmann ef55626296 👷 added Clang 3.9-5.0
Taken from
https://github.com/travis-ci/docs-travis-ci-com/pull/746/files.
2017-04-11 20:37:38 +02:00
Niels Lohmann 5bea6f383a ✏️ fixed a typo 2017-04-11 18:57:53 +02:00
Niels Lohmann 4c161161f0 Merge branch 'feature/vs2017' into develop 2017-04-10 19:51:58 +02:00
Niels Lohmann d7e57e3b73 🔨 added an output adapter for the binary writer 2017-04-09 22:13:26 +02:00
Niels Lohmann f3e43d7c6f 🔨 some cleanup 2017-04-09 21:14:51 +02:00
Niels Lohmann 186a9fd44d 🔨 simplified interface for parser, lexer, and binary_reader
These classes are now constructed with an interface adapter. This moves
complexity from various places into the interface adapter class, or to
some factories which now implement the different flavors of input.

Furthermore, input adapters are kept in std::shared_ptr to avoid the
need of manual deletion.
2017-04-09 19:28:15 +02:00
Niels Lohmann e48114bbd6 🔨 check for value of _HAS_CXX17 2017-04-09 14:02:04 +02:00
Niels Lohmann 628be157a2 🐛 added fix for #464 2017-04-09 13:52:04 +02:00
Niels Lohmann c40c8ac92e 👷 excluding MSVC 2015 with "/permissive- /std:c++latest /utf-8" 2017-04-09 12:00:30 +02:00
Niels Lohmann a9f4094580 👷 another try 2017-04-09 11:47:31 +02:00
Niels Lohmann 180d249f6c 👷 another try 2017-04-09 11:38:42 +02:00
Niels Lohmann d3d87674c8 👷 fixed AppVeyor syntax 2017-04-09 11:00:39 +02:00
Niels Lohmann 9d9c5216d7 👷 additional flags for MSVC #464
To test a fix for issue #464 (not yet implemented), we first need to
have  an MSVC build with “/permissive- /std:c++latest /utf-8”.
2017-04-09 10:59:45 +02:00
Niels Lohmann 6f99d5b2e9 🔨 fixed test case
One test case for CBOR and MessagePack assumed little endianess.
2017-04-08 23:39:17 +02:00
Niels Lohmann d4e49873b7 👷 experimenting with configurations 2017-04-08 21:56:42 +02:00
Niels Lohmann 97a25de938 proposal for #428
This implementation forwards the iterators to std::map::insert.
2017-04-07 18:29:09 +02:00
Niels Lohmann d62d48fc48 🔀 merge branch 'develop' into feature/manual_lexer 2017-04-07 17:19:52 +02:00
Niels Lohmann 90273e930c 🐛 fix for #512
We totally forgot to implement the comparison operators other than ==
and != for scalar types. Consequently, comparing a JSON value with a
scalar type led to compile errors.
2017-04-07 15:44:41 +02:00
Niels Lohmann ff72f38863 🔨 fixed another warning
Do not store eof() in a char buffer…
2017-04-06 19:54:08 +02:00
Niels Lohmann b992acc2e7 🔨 fixed a compiler warning 2017-04-05 20:39:27 +02:00
Niels Lohmann 08fdfcca9a 🔨 implemented a binary writer 2017-04-04 23:17:43 +02:00
Niels Lohmann c28bf823bc 🔨 added endianess check 2017-04-04 17:30:43 +02:00
Niels Lohmann b15fc13dd1 🔨 implemented MessagePack in binary_reader 2017-04-04 16:59:19 +02:00
Niels Lohmann 3a34f2d82c Merge branch 'develop' into feature/manual_lexer 2017-04-04 15:55:40 +02:00
Niels Lohmann 782570d46f 🔨 cleanup 2017-04-03 22:58:46 +02:00
Niels Lohmann 4f6b63e492 Merge pull request #545 from theodelrieu/feature/enum_class_support
add enum class default conversions
2017-04-03 22:13:59 +02:00
Niels Lohmann ea667db446 🔨 fixed compilation errors
TIL about C++:

executing m[key()]=val(); for a std::map executes

First key() then val() with Clang

First val() then key() with GCC

#wat
2017-04-03 21:53:23 +02:00
Niels Lohmann 89efe627fe 🔨 a lot of restructuring
- removed uncached input stream adapter; it was too slow anyway
- implemented a class binary_read which parses CBOR based on input
adapters
- in the CBOR parser, numbers are created via memcpy to avoid undefined
behavior
2017-04-02 18:46:21 +02:00
Théo DELRIEU af9b21151c add enum class default conversions 2017-04-02 13:10:15 +02:00
Niels Lohmann 3a5cf9bd0a 🔨 improved code coverage 2017-04-01 08:34:58 +02:00
Niels Lohmann c32d2e5b3c 🔨 removed unget() function 2017-04-01 00:36:05 +02:00
Niels Lohmann 8d393b5eff Merge branch 'develop' into feature/manual_lexer 2017-03-31 23:58:45 +02:00
Niels Lohmann 3fa0610856 🔨 added minibench to ignore list 2017-03-31 23:57:24 +02:00
Niels Lohmann 50ee0a62f5 🔨 replaced lookup-tables by switches 2017-03-31 23:24:33 +02:00
Niels Lohmann 4c821c9e9c 🔨 moved buffer size to interface 2017-03-31 17:11:51 +02:00
Niels Lohmann d07596a0ea 📝 mentioned #540 and fixed #538 2017-03-30 17:39:02 +02:00
Niels Lohmann 7881783745 Merge pull request #540 from tinloaf/diagnostics
Properly pop diagnostics
2017-03-30 17:25:29 +02:00
Lukas Barth 0b1b6307a5 Also change the re2c file 2017-03-30 16:14:02 +02:00
Lukas Barth 40aff4182f Pop for every push 2017-03-30 16:10:03 +02:00
Niels Lohmann 60057a4728 🔨 fixed bugs introduced by merging from develop 2017-03-29 07:54:26 +02:00
Niels Lohmann a690a9f2d2 Merge branch 'develop' into feature/manual_lexer 2017-03-29 00:57:09 +02:00
Niels Lohmann c2e80a72d7 🔨 deprecated j << istream / j >> ostream functions #367
The implementation is non-standard. Deprecation allows a simpler API in
the future without removing any features.
2017-03-29 00:39:47 +02:00
Niels Lohmann 9578c0f700 Merge branch 'develop' into feature/manual_lexer 2017-03-28 23:47:17 +02:00
Niels Lohmann b4dbebffcd added regression test for #464 2017-03-28 23:28:54 +02:00
Niels Lohmann 62dfdf3f5d 📝 addressed #514
NaN values never compare equal to themselves or to other NaN values.
2017-03-28 23:24:59 +02:00
Niels Lohmann 5d586b0192 🔨 cleanup 2017-03-28 23:20:45 +02:00
Niels Lohmann 19d119e18c 🔨 fixed a warning in MSVC 2017-03-28 22:10:24 +02:00
Niels Lohmann 6b12e40478 🏁 removed __builtin_expect for MSVC 2017-03-28 21:55:26 +02:00
Niels Lohmann d025b6aaf7 Merge branch 'develop' into feature/manual_lexer 2017-03-28 21:39:36 +02:00
Niels Lohmann 19cd206d99 📝 documented Xcode 8.3 2017-03-28 21:39:16 +02:00
Niels Lohmann a0aa6ad2b2 👷 added Xcode 8.3
https://blog.travis-ci.com/2017-03-28-xcode-83-ga-is-here
2017-03-28 20:42:12 +02:00
Niels Lohmann d37ca2eba8 🔨 fixed test case 2017-03-28 20:29:27 +02:00
Niels Lohmann 50e251f5f6 🔨 adjusted test case to new signature of token_type_name() 2017-03-28 20:17:00 +02:00
Niels Lohmann 6a6fbea62c 🔨 some cleanup 2017-03-28 20:08:08 +02:00
Niels Lohmann 1e495945f1 🔨 fixed buffer overflow 2017-03-28 18:06:43 +02:00
Niels Lohmann bbb6bd9de5 🔨 fixing last failing test cases 2017-03-28 17:00:03 +02:00
Niels Lohmann b0c47abd88 🔨 rewrote string parser to cope with UTF-8 2017-03-27 22:58:44 +02:00
Niels Lohmann f75e195db3 🔨 added code for user-defined number types 2017-03-26 18:45:04 +02:00
Niels Lohmann 3425527970 🔨 added code for locale-independent number parsing 2017-03-26 18:12:58 +02:00
Niels Lohmann 06e2a291b1 🔨 fixed number parsing 2017-03-26 17:26:41 +02:00
Niels Lohmann 3b069b4b4c 🔨 adjusted more expected exceptions 2017-03-26 16:19:07 +02:00
Niels Lohmann 99e0d8b339 🔨 fixed \uxxxx parsing 2017-03-26 15:29:08 +02:00
Niels Lohmann f47cf152a8 Merge branch 'develop' into feature/manual_lexer 2017-03-26 13:14:14 +02:00
Niels Lohmann d4d51460ab Merge branch 'feature/noexcept_exceptions' into develop 2017-03-26 12:54:22 +02:00
Niels Lohmann 3336194306 🔨 reverted changes that led to Travis failures 2017-03-26 12:23:10 +02:00
Niels Lohmann 53b501a785 🔨 cleanup 2017-03-25 23:31:03 +01:00
Niels Lohmann cf7786887c 🔨 fixed check for is_nothrow_copy_constructible
We now only demand our exceptions to be is_nothrow_copy_constructible
if std::runtime_exception is.
2017-03-25 17:35:57 +01:00
Niels Lohmann c333679a96 🔨 small refactoring
The solution with a std::runtime_error member is more elegant. It
allows to have std::exception as base class again. However, I still
have no idea why GCC thinks the copy constructor may throw...
2017-03-25 17:25:39 +01:00
Niels Lohmann cc36c65a89 🚑 made exceptions nothrow-copy-constructible #531
To have nothrow-copy-constructible exceptions, we inherit from
std::runtime_error which can cope with arbitrary-length error messages.
Intermediate strings are built with static functions and then passed to
the actual constructor.
2017-03-25 16:22:52 +01:00
Niels Lohmann a58ed3cd17 💄 cleanup 2017-03-25 14:47:23 +01:00
Niels Lohmann 20bcf1015b 📝 cleanup after #536 2017-03-25 14:19:05 +01:00
Niels Lohmann dc6e9b6188 Merge branch 'develop' into feature/manual_lexer 2017-03-25 14:12:58 +01:00
Niels Lohmann 0f9585685a Merge pull request #536 from vpetrigo/feature/VS17_appveyor_support
Add Visual Studio 17 image to appveyor build matrix
2017-03-25 14:12:30 +01:00
Vladimir Petrigo 8edb0cd15c Add VS17 image to appveyor matrix 2017-03-25 14:57:58 +03:00
Niels Lohmann a93ec07c8c Merge branch 'develop' into feature/manual_lexer 2017-03-24 19:53:19 +01:00
Niels Lohmann 3d597dda5d 📝 update after #534 2017-03-24 19:51:11 +01:00
Niels Lohmann 40160f482a 🚧 manual lexer
This commit removed the re2c lexer and replaced it by a manual version.
Its integration is not yet complete: number parsing does not respect
locales or overflows. Furthermore, parsing does not need to end with
EOF. Therefore, a lot of test cases fail. The idea is to push this
branch forward so we can conduct performance comparisons. So far, a
nice side effect are better diagnosis messages in case of parse errors.
2017-03-24 19:49:02 +01:00
Niels Lohmann bba688f53e Merge pull request #534 from TedLyngmo/utf8_encoding_enhancement
UTF8 encoding enhancement
2017-03-24 19:38:29 +01:00
Ted Lyngmo cea2426731 UTF8 encoding enhancement 2017-03-24 14:56:48 +01:00
Niels Lohmann 8a872927e8 Merge pull request #530 from berkus/patch-1
Fix typo
2017-03-23 13:57:54 +01:00
Berkus Decker b14629b0a6 Fix typo 2017-03-23 14:50:41 +02:00
Niels Lohmann 54db53c230 📝 update after #527 and #525 2017-03-22 08:10:31 +01:00
Niels Lohmann d60851168e 🚨 fixed a compiler warning #527
The result of snprintf is later used in situations where a long may
overflow.
2017-03-22 08:10:02 +01:00
Niels Lohmann 67a06834b0 Merge pull request #526 from krzysztofwos/feature/exception-base-class
Make exception base class visible in basic_json
2017-03-22 07:50:34 +01:00
Krzysztof Woś b9c3b8d688 Exit with an error if re2c is not available
Instead of overwriting src/json.hpp with an empty file
2017-03-20 16:00:58 +09:00
Krzysztof Woś 86579209c8 Make exception base class visible in basic_json 2017-03-20 16:00:58 +09:00
Niels Lohmann 31a6c0910e 🚑 fix for #519
Added catch branch for out_of_range exception that can occur if input
file contains a number overflow.
2017-03-17 22:18:48 +01:00
Niels Lohmann f547679de5 🚑 fix for #516 and #518
We should compare the binary serializations rather than the JSON values
themselves. This fix was already done for CBOR and apparently forgotten
for MessagePack.
2017-03-17 22:18:05 +01:00
Niels Lohmann 2d474b5273 Merge pull request #510 from alex-weej/patch-1
🎨 Namespace `uint8_t` from the C++ stdlib
2017-03-17 06:47:11 +01:00
Alexander “weej” Jones 836f1c4189 🎨 Namespace uint8_t from the C++ stdlib 2017-03-16 18:24:41 +00:00
Niels Lohmann cd43600e6f 💄 cleanup after #508 2017-03-16 19:02:05 +01:00
Niels Lohmann 773b33e016 Merge pull request #508 from theodelrieu/feature/c_array_conversion
add to_json method for C arrays
2017-03-16 19:00:58 +01:00
Niels Lohmann c5711f3072 🚧 a lot of minor changes
- Removed unused headers.
- Added override where needed.
- Added description for parse_error.113 exception.
- Fixed some conversion warnings.
- Integrated cbor_expect_string function for CBOR maps.
- Added documentation on the supported CBOR/MessagePack features.
- Added test to check all initial bytes for CBOR input.
2017-03-16 18:39:33 +01:00
Niels Lohmann 483a58f625 🚨 added pedantic flags for GCC
With GCC 7, there are even more diagnostic flags.
2017-03-16 18:35:45 +01:00
Théo DELRIEU dbebf8de47 add to_json method for C arrays
If the array can be converted to basic_json::string_t, the overload
in this commit is not chosen.
2017-03-16 15:20:39 +01:00
Niels Lohmann 100bf3ef2c Merge branch 'feature/getline' into develop 2017-03-14 23:08:19 +01:00
Niels Lohmann 710f8a2686 📝 improved documentation for to-CBOR and to-msgpack functions 2017-03-14 23:08:05 +01:00
Niels Lohmann 1de80e8af4 🔨 added user-defined exception #493
Replaced old std::invalid_argument exception by parse_error.111 to have
unified exceptions in case of input stream errors.
2017-03-14 21:31:36 +01:00
Niels Lohmann 63c2c62f19 🔨 changed call from "not good()" to "fail()" #493
Also merged develop into this feature branch.
2017-03-14 21:24:53 +01:00
Niels Lohmann 95474e420d 🏁 added parentheses around max/min calls #506
When <Windows.h> is included with MSVC, a macro NOMINMAX is defined
that yields compilation errors when max/min calls are encountered. This
can be fixed by un-defining NOMINMAX, or by placing parentheses around
all min/max calls. We chose the latter.
2017-03-14 21:11:20 +01:00
Niels Lohmann b026591e9e 🚑 added special case to fuzzers to fix #504
Since #329, NaN and inf numbers do not yield an exception, but are
stored internally and are dumped as “null”. This commit adjusts the
fuzz testers to deal with this special case.
2017-03-14 21:05:38 +01:00
Niels Lohmann bfe4788e32 🚑 fix for #500
Removed a check that already failed in MSVC.
2017-03-14 16:14:05 +01:00
Niels Lohmann 84072fbd6d 💄 fixed indentation 2017-03-14 16:07:28 +01:00
Niels Lohmann b8b4362ca4 🔥 removed accidentally committed binaries 2017-03-13 19:04:19 +01:00
Niels Lohmann c5cf32e34d 🔨 added user-defined exception 406 2017-03-12 20:59:33 +01:00
Niels Lohmann 43b8285249 🔀 merge branch 'feature/exceptions_3.0.0' into develop 2017-03-12 20:34:30 +01:00
Niels Lohmann 855cdcf05c 🔀 merge branch 'develop' into feature/exceptions_3.0.0 2017-03-12 20:22:30 +01:00
Niels Lohmann 8feaf8dc94 💥 implemented new handling of NaN and INF #70 #329 #388
- If an overflow occurs during parsing a number from a JSON text, an
exception (std::out_of_range for the moment, to be replaced by a
user-defined exception #244) is thrown so that the overflow is detected
early and roundtripping is guaranteed.
- NaN and INF floating-point values can be stored in a JSON value and
are not replaced by null. That is, the basic_json class behaves like
double in this regard (no exception occurs). However, NaN and INF are
serialized to “null”.
- Adjusted test cases appropriately.
2017-03-12 18:38:05 +01:00
Niels Lohmann 9355f05888 🔨 cleaned up array from_json methods #473
Removed some code that is not needed any more. Thus, streamlining the
array from_json methods.
2017-03-12 17:05:02 +01:00
Niels Lohmann 87eafd8d6a added regression tests for #473
These tests currently pass without any adjustments to the source code.
2017-03-12 15:20:17 +01:00
Niels Lohmann 80dcf22fc3 🔨 added a check function for MsgPack strings #497
To avoid the error described in #497, I added a function
msgpack_expect_string that is executed every time a string is expected
during the parsing of a map. In case the current byte does not belong
to a MsgPack string, an exception is thrown.
2017-03-12 14:39:20 +01:00
Niels Lohmann 28dbe4e651 📝 overworked documentation for the at functions
Added all possible exceptions to the examples of the at functions.
2017-03-12 13:49:39 +01:00
Niels Lohmann 89f6068385 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-12 11:51:24 +01:00
Niels Lohmann dfa4e83cd8 Merge branch 'feature/no_exceptions' into develop 2017-03-12 11:49:52 +01:00
Niels Lohmann e3e941ef2b 👷 fixed a syntax error 2017-03-12 11:19:27 +01:00
Niels Lohmann 01470f388b 👷 fixed no_exceptions test case
This test case relied on logics that have been replaced by CMake with
#461. This change enables compilation and execution of the test suite
without exceptions by adding an after_success task.
2017-03-12 11:04:26 +01:00
Niels Lohmann 4d7c29923e 🚑 fix for #486
Implemented std::less<value_t> to allow using value_t as std::map key
in MSVC.
2017-03-12 10:40:36 +01:00
Niels Lohmann 4b9c2f1287 🔨 added __EXCEPTIONS to the list 2017-03-11 20:16:13 +01:00
Niels Lohmann 4e49829851 🚑 fix for #493
Added a test to check if the input stream is good() before executing
getline on it. Also added two test cases that set the failbit and
badbit before calling file_line_buffer.
2017-03-11 19:26:12 +01:00
Niels Lohmann 122afbf128 🔨 added defined() check 2017-03-11 18:43:21 +01:00
Niels Lohmann e3e6cbecc7 🏁 added check for _CPPUNWIND
MSVC does not define __cpp_exceptions, but seems to use _CPPUNWIND when
exception support is switched on, see
https://msdn.microsoft.com/en-us/library/b0084kay.aspx.
2017-03-11 17:59:24 +01:00
Niels Lohmann 65dfc97d40 🔨 using __cpp_exceptions to detect exception support #498
I used __EXCEPTIONS to detect whether exceptions are supported.
Apparently, this is a macro that is only used by libstdc++
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64276). It’s much cleaner
to use __cpp_exceptions as it is in the standard since C++98.

Note that compiling the unit-tests with “-fno-exceptions” still does
not work, because Catch uses throw internally. However, the library’s
exceptions can be switched off by defining JSON_NOEXCEPTION.
2017-03-11 17:44:54 +01:00
Niels Lohmann ff0b18d10c Merge branch 'feature/vector_bool' into develop 2017-03-11 17:22:14 +01:00
Niels Lohmann c7afb34e57 🎨 cleanup after #496
Ran “make pretty” and added a note to the README file.
2017-03-11 16:01:26 +01:00
Niels Lohmann 754ce0b991 Merge pull request #496 from TedLyngmo/fix_effcplusplus_warnings
Fix -Weffc++ warnings (GNU 6.3.1)
2017-03-11 15:57:10 +01:00
Niels Lohmann d9e2dd03bf 🔨 fixed interface for to_json function 2017-03-11 15:46:52 +01:00
Niels Lohmann f4126e4dd8 added overload for std::less<value_t> #486
MSVC needs this overload to compile code containing a std::map that
uses nlohmann::detail::operator as key.
2017-03-11 15:44:14 +01:00
Niels Lohmann f5f6dac800 added overload for std::vector<bool> #494
Adds a to_json function for std::vector<bool> to allow implicit
conversion from bit vectors to basic_json.
2017-03-11 15:32:44 +01:00
Ted Lyngmo 70bbf19527 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 15:16:26 +01:00
Ted Lyngmo 5b809b9737 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 15:05:21 +01:00
Ted Lyngmo 9cfb777b65 Fix -Weffc++ warnings (GNU 6.3.1) 2017-03-11 13:56:38 +01:00
Niels Lohmann f9fe0193d5 Merge branch 'develop' into coverity_scan 2017-03-09 18:55:27 +01:00
Niels Lohmann 758c4addc1 🚑 fix for #492
The original test case relied on an invalidated iterator. This error
did not occur before, but only with GCC with -D_GLIBCXX_DEBUG. This
commit fixes the test case. The library is unaffected by this change.
2017-03-09 18:20:26 +01:00
Niels Lohmann 0f6b8aa718 📝 more documentation for the new exceptions 2017-03-08 23:30:38 +01:00
Niels Lohmann 1ab580d6e9 📝 more documentation for the new exceptions 2017-03-08 23:12:13 +01:00
Niels Lohmann fe71e7df1f 📝 overworked documentation
Replacing references to std exceptions with user-defined exceptions.
Also changed some examples to the new exceptions.
2017-03-08 21:03:19 +01:00
Niels Lohmann 9374eaa013 🔨 added user-defined exception 501 2017-03-08 19:16:53 +01:00
Niels Lohmann c8a6ce79ea 🚑 fixing fuzzers to work with new exceptions 2017-03-08 18:37:03 +01:00
Niels Lohmann fc9b528ec9 🔨 changed an exception 2017-03-08 18:07:21 +01:00
Niels Lohmann 8fcd01631f improved test coverage
Tests for parse_error.109 were missing.
2017-03-08 16:39:17 +01:00
Niels Lohmann 625cf7e3f7 🔨 added user-defined exception 112 2017-03-07 20:05:34 +01:00
Niels Lohmann 757d2c6c7a 🔨 replaced at() calls in msgpack/cbor 2017-03-06 23:45:08 +01:00
Niels Lohmann 5407333224 🔨 added user-defined exception 111 2017-03-06 22:37:46 +01:00
Niels Lohmann 21ec0e7806 🔨 added user-defined exception 110 2017-03-06 21:00:13 +01:00
Niels Lohmann a186106bde 🔨 user-defined exception 302
Also moved all exception classes into the detail namespace and
introduced them via “using” into basic_json.
2017-03-06 19:34:44 +01:00
Niels Lohmann 38c2e20ce8 added user-defined exceptions 404-405 2017-03-05 23:25:22 +01:00
Niels Lohmann 30331fa21f 🔨 added user-defined exception 403 2017-03-05 23:16:17 +01:00
Niels Lohmann 60da36aee2 🔨 added user-defined exceptions 401-402 2017-03-05 22:56:39 +01:00
Niels Lohmann 491c9780a7 🔨 added user-defined exception 311 2017-03-05 22:39:21 +01:00
Niels Lohmann 6751d650be 🔨 added user-defined exception 311 2017-03-05 22:31:08 +01:00
Niels Lohmann 9e560ca40c 🔨 added user-defined exceptions 313-315 2017-03-05 19:58:26 +01:00
Niels Lohmann 144cf6a4c7 🔨 added user-defined exceptions 310 2017-03-05 19:48:11 +01:00
Niels Lohmann 5cca44c161 🔨 added user-defined exceptions 309 2017-03-05 19:42:05 +01:00
Niels Lohmann 70b2c3f45e 🔨 added user-defined exceptions 308 2017-03-05 19:35:24 +01:00
Niels Lohmann 2a9393af00 🔨 added user-defined exceptions 307 2017-03-05 19:26:44 +01:00
Niels Lohmann bb740c43fb 🔨 added user-defined exceptions 306 2017-03-05 19:15:56 +01:00
Niels Lohmann aa842b4a27 🔨 added user-defined exceptions 305 2017-03-05 19:08:12 +01:00
Niels Lohmann f473f74fb0 🔨 added user-defined exceptions 303-304 2017-03-05 18:56:35 +01:00
Niels Lohmann 068c7acda9 🔨 added user-defined exceptions 301 2017-03-05 18:40:09 +01:00
Niels Lohmann 0c40c8e3be 🔨 added user-defined exceptions 2xx 2017-03-03 14:34:57 +01:00
Niels Lohmann a4274d7766 🔨 added user-defined exceptions 205-206 2017-03-03 14:00:42 +01:00
Niels Lohmann 875b2da95d 🔨 added user-defined exceptions 203-204 2017-03-03 13:38:14 +01:00
Niels Lohmann 9381f6c4da 🔨 added user-defined exceptions 201-202
Started implementing exceptions for invalid iterators.
2017-03-03 13:19:45 +01:00
Niels Lohmann e291c6c3d2 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-03 12:59:37 +01:00
Niels Lohmann a1354184ce 📝 fixed typo #481 2017-03-03 12:56:54 +01:00
Niels Lohmann 0c6b1f8a24 Merge branch 'develop' into feature/exceptions_3.0.0 2017-03-03 12:54:45 +01:00
Niels Lohmann 776758d7a2 🔨 added user-defined exception 109
This exception occurs when a JSON pointer contains an array index that
can not be converted into a number.
2017-03-03 12:54:37 +01:00
Niels Lohmann b86d2148ef 🔨 added user-defined exceptions 106-108
These exceptions occur when JSON pointers are malformed.
2017-03-03 11:56:58 +01:00
Niels Lohmann 06c788e4fd 📝 added missing word 2017-03-03 10:01:16 +01:00
Niels Lohmann 01d3a006b1 ⬆️ updated Catch to v1.8.1 2017-03-02 18:13:19 +01:00
Niels Lohmann 06815d274e 🔨 added user-defined exceptions 104 and 105
These exceptions are thrown in case of parse errors in JSON patch
documents.
2017-03-02 17:55:13 +01:00
Niels Lohmann c085e3bac2 🔨 started with user-defined exceptions #301 #244
Added class hierarchy for user-defined exceptions (#244). Integrated
parse exceptions 101-103. Parse exceptions include the byte count of
the last read character to locate the position of the error (#301).
2017-03-01 21:28:44 +01:00
Niels Lohmann 7b8fd864e2 🔥 removed deprecated constructor #480
The constructor basic_json(std::istream&, const parser_callback_t) has
been deprecated since version 2.0.0. This commit removes it together
with its code example, deprecation macro, and test cases. The code now
also compiles with -W-deprecated-declarations.
2017-03-01 17:49:03 +01:00
Niels Lohmann 6b3912d936 📝 added note to 3.0.0 wiki page #474
I created a wiki page
https://github.com/nlohmann/json/wiki/Road-toward-3.0.0 to describe the
transition toward version 3.0.0. On this page, all API-breaking changes
shall be documented.
2017-03-01 17:26:32 +01:00
Niels Lohmann f84ac523aa 📝 added a note to ordered maps
The library does not preserve the insertion order of object keys. There
are frequent requests to change the library in this aspect. The README
and the contribution guidelines now contain links to containers that
can be used to replace std::map to preserve the insertion order.
2017-03-01 10:15:07 +01:00
Niels Lohmann 41f9b32554 🔀 merge branch 'feature/serialization_class' into develop (#418)
Moved all dump()-related functions into a class "serializer". This fix includes a lot of performance improvements yielding a 7% speedup for serialization. Details on the individual steps can be found in the commit messages.

Individual benchmark numbers:

before:

dump jeopardy.json                            5   374555228 ns/op
dump jeopardy.json with indent                5   430953700 ns/op
dump numbers/floats.json                      5   622938509 ns/op
dump numbers/signed_ints.json                20    82177979 ns/op

after:

dump jeopardy.json                            5   335449757 ns/op -11%
dump jeopardy.json with indent                5   375467773 ns/op -13%
dump numbers/floats.json                      5   584611852 ns/op -7%
dump numbers/signed_ints.json                20    68289574 ns/op -17%
2017-02-28 21:04:16 +01:00
Niels Lohmann d69242c6ba 💄 cleanup
- Added comments for the serializer class.
- Added test case for resizing of the indentation string.
- Using std::none_of to check if “.0” needs to be added to
floating-point number.
2017-02-28 19:20:50 +01:00
Niels Lohmann 059f21aada 💄 fixed a warning
snprintf returns an int, but we later assign it a difference_type which
is usually a long.
2017-02-28 17:24:03 +01:00
Niels Lohmann 224f99070b micro-optimization of dump()
A lot of small changes to avoid memory allocations:

- The locale is only queried once rather than with every number
serialization.
- The indentation string is recycled between different calls.
- The string escape function avoids a copy if no escaping is necessary.
- The string escape and the space function use a complete switch case
instead of cascaded ifs.

Cachegrind measures some 15% performance improvement.
2017-02-28 16:28:22 +01:00
Niels Lohmann fc48b8ac2b 🐛 fixed a logical error
Treated the size of the range as the number of thousand separators.
This logical error yielded a negative value for written_bytes and
eventually an infinite loop, as written_bytes was converted to an
unsigned value.
2017-02-28 11:45:38 +01:00
Niels Lohmann af070744ae 🔨 integrating numtostr into serializer class
By merging numtostr into serializer, we can write directly to the
output stream. As a consequence, all stream calls are now unformatted.
2017-02-27 22:10:57 +01:00
Niels Lohmann 54ef5f7b47 🔨 moved serialization functions to serializer class
The class is currently just a wrapper for an std::ostream and collects
all functions related to serialization. The next step should be
recycling of variables to avoid repetitive initialization for each
recursive dump call.
2017-02-27 21:22:39 +01:00
Niels Lohmann 9c4919ff34 " micro-optimizations for dump()"
This reverts commit 909b439b03.
For some strange reason, the test suite crashes when compiled
with GCC.
2017-02-27 16:19:07 +01:00
Niels Lohmann 909b439b03 micro-optimizations for dump()
numtostr now directly writes to a stream. Return value of snprintf is
reused to avoid finding end of string. Cachegrind suggests a 1%
performance increase.
2017-02-27 14:58:10 +01:00
Niels Lohmann 0f04e42dd5 micro-optimizations for dump()
All ‘<<‘ calls have been replaced by write()/put() calls. The
indentation strings needs not to be resized. Cachegrind measures 1%
performance improvement.
2017-02-27 01:22:24 +01:00
Niels Lohmann b1441f3485 micro-optimizations for dump()
Indentation string is recycled to avoid allocations. Comma-separation
in objects does not need an if any more. Cachegrind measures 1%
performance improvement.
2017-02-26 20:58:00 +01:00
Niels Lohmann bd0326cbc1 micro-optimizations for dump()
Added separate code paths for normal output and pritty-printed output.
This allowed to remove most of the ifs along the way. Benchmarks and
cachegrind suggest a 10% performance improvement.
2017-02-26 16:55:54 +01:00
Niels Lohmann ae155c4734 💄 cleanup 2017-02-26 14:45:41 +01:00
Niels Lohmann bf4d744d1a more tests for meta() call 2017-02-26 14:34:58 +01:00
Niels Lohmann d1b30250d6 added missing tests 2017-02-26 11:50:52 +01:00
Niels Lohmann f1cd15ce7e avoid copying a string 2017-02-26 11:22:18 +01:00
Niels Lohmann 9ff0cc0f02 📝 updated documentation 2017-02-25 16:43:15 +01:00
Niels Lohmann 03f06e1993 Merge branch 'develop' into coverity_scan 2017-02-25 16:38:18 +01:00
Niels Lohmann 1b5867bdcf 🔀 merge branch 'release/2.1.1' into develop 2017-02-25 16:37:28 +01:00
Niels Lohmann c0d511ea50 🔀 merge branch 'release/2.1.1' 2017-02-25 16:36:46 +01:00
Niels Lohmann 27c65b860b 🔖 version 2.1.1 2017-02-25 16:34:38 +01:00
Niels Lohmann 0234e53e23 📝 added section on used third-party tools 2017-02-22 20:48:52 +01:00
Niels Lohmann b49ce351eb 💄 fixed some warnings 2017-02-22 20:48:29 +01:00
Niels Lohmann a646c9c599 🔀 merge branch 'cotire' of https://github.com/tusharpm/json into tusharpm-cotire 2017-02-22 19:45:10 +01:00
Niels Lohmann 8cec55a271 🚧 fixed more warnings 2017-02-22 18:14:29 +01:00
Niels Lohmann 345a106d73 💄 cleanup 2017-02-22 16:56:56 +01:00
Niels Lohmann 967f9144d4 🚧 overworked fix for #465 2017-02-21 19:11:34 +01:00
Niels Lohmann 7d14f167b8 🚑 fix for #465 2017-02-20 22:48:27 +01:00
Niels Lohmann b04543ecc5 🎨 fixed newlines 2017-02-20 21:56:10 +01:00
Niels Lohmann 1a6d7f5bca 🚧 try to fix some warnings in MSVC 2017-02-20 18:32:11 +01:00
Niels Lohmann f7075be93a 🐛 reverted change for #464 2017-02-20 18:15:50 +01:00
Niels Lohmann f2dfa09aec 🐛 fix for #464 2017-02-20 18:05:52 +01:00
Niels Lohmann 83a9c60dbd 🔨 refactored code to avoid using strcpy/strlen/strcat (#463) 2017-02-20 17:37:34 +01:00
Niels Lohmann 716485a965 🚧 removed decay (#448) 2017-02-20 16:27:16 +01:00
Niels Lohmann 7a4a16a7db 💄 updated header list 2017-02-20 16:20:45 +01:00
Niels Lohmann 1f72c38861 🚑 fix for #448 2017-02-19 21:26:53 +01:00
Niels Lohmann 83f1d2c81b added start index for from_cbor and from_msgpack (#462) 2017-02-19 21:17:05 +01:00
Niels Lohmann 4151f2d297 added test with thousands_sep 2017-02-19 20:08:01 +01:00
Niels Lohmann 5b53f03e7c Merge branch 'develop' into TurpentineDistillery-feature/locale_independent_num_to_str 2017-02-19 19:24:55 +01:00
Niels Lohmann 9a9d0ba3df 🚧 fixing warning C4293 (#453) 2017-02-19 17:47:20 +01:00
Tushar Maheshwari 5436407b7e 👷 Add cmake logic to Travis config
- get CMake for XCode 8.1 image
2017-02-19 13:38:08 +05:30
Tushar Maheshwari 85ce4d7b53 cmake compile time reduce using cotire
- Add prefix header
  - Include catch.hpp
  - Include json.hpp
    - Replace private with public for all json_unit files
- Move `unit.cpp` to an object library
- cotire issue: strip whitespace from CMAKE_INCLUDE_SYSTEM_FLAG_CXX
2017-02-19 13:35:54 +05:30
Niels Lohmann d1479e47bb 💄 added assertion message 2017-02-18 11:01:03 +01:00
Niels Lohmann 513eb3ab5f 🚧 clean up 2017-02-18 11:00:18 +01:00
Niels Lohmann 0200f2dc62 🚧 fixing warning C4267 (#453) 2017-02-17 19:14:21 +01:00
Niels Lohmann 6408402ad2 🔀 merge #378 (for #362 and #454) 2017-02-16 09:24:45 +01:00
Niels Lohmann 057b1e606b 🔀 merged #415 (fix for #414) 2017-02-16 08:50:20 +01:00
Niels Lohmann 2c17c1b1b2 💄 cleanup 2017-02-16 08:01:01 +01:00
Niels Lohmann 973402c11e 🚧 replaced throws (#440) and _MAX/_MIN macros (#451) 2017-02-15 22:44:18 +01:00
Niels Lohmann b9f3149451 🚑 fix for #452 2017-02-15 21:30:28 +01:00
Mihai STAN 6bf93b3d06 Merge remote-tracking branch 'upstream/develop' into develop 2017-02-15 15:00:25 +02:00
Niels Lohmann 82fb613763 📝 update after #302 2017-02-14 07:28:30 +01:00
Niels Lohmann 22b9a301d6 Merge pull request #450 from nlohmann/TurpentineDistillery-feature/locale_independent_str_to_num
TurpentineDistillery feature/locale independent str to num
2017-02-14 07:18:35 +01:00
Niels Lohmann c95ff863bf ⬆️ updated Catch to v1.7.2 2017-02-13 18:55:11 +01:00
Niels Lohmann 265c5b5207 🔨 more work on the number parser 2017-02-13 18:51:23 +01:00
Niels Lohmann b84705d557 improved test coverage 2017-02-12 20:14:43 +01:00
Niels Lohmann c8191c8172 🔨 further cleanup 2017-02-12 18:50:17 +01:00
Niels Lohmann c2d55109c1 🔨 make lexer distinguishes number types 2017-02-11 16:54:25 +01:00
Niels Lohmann 9f5dccbab5 💄 cleanup 2017-02-11 15:55:53 +01:00
Niels Lohmann 926af6d50b 🔀 merge branch 'develop' into TurpentineDistillery-feature/locale_independent_str_to_num 2017-02-11 15:17:47 +01:00
Niels Lohmann ed8516dc39 👷 added Codacy badge 2017-02-09 17:38:02 +01:00
Niels Lohmann c485d46cea 📝 screenshoots look ugly 2017-02-08 20:00:46 +01:00
Niels Lohmann 6fd77cea4a 📝 added screenshots 2017-02-08 19:22:19 +01:00
Niels Lohmann 0ffa18aab8 📝 listing projects using the library 2017-02-08 19:16:38 +01:00
Niels Lohmann 662a9b8f3c ✏️ fixed more typos 2017-02-08 18:19:41 +01:00
Niels Lohmann 4746a4c536 💄 minor change 2017-02-08 17:56:43 +01:00
Niels Lohmann 163f8397fd ✏️ fixed a typo #446 2017-02-05 17:11:26 +01:00
Niels Lohmann 8d88a1da2a 🔀 merged #379 and fixed conflicts 2017-02-05 13:13:41 +01:00
Niels Lohmann d284c86dd1 uncommented some tests 2017-02-04 21:00:41 +01:00
Niels Lohmann 922fe693e1 ⬆️ updated Catch to v1.7.0 2017-02-04 15:30:28 +01:00
Niels Lohmann 1cfdc2a753 🐛 fixed test compilation 2017-02-04 08:25:55 +01:00
Niels Lohmann 77d6f70602 📝 acknowledgments for #442 and #445 2017-02-03 18:28:22 +01:00
Niels Lohmann d6afaa8e16 📝 fixing a documentation issue #442 2017-02-03 18:15:37 +01:00
Niels Lohmann 5976caf032 improved test compilation speed #445 2017-02-03 18:09:55 +01:00
Niels Lohmann 16af771277 added roundtrip test for the Big List of Naughty Strings 2017-02-01 17:34:39 +01:00
Niels Lohmann bf8fdac99a 👷 dropped Doozer.io support 2017-02-01 16:41:05 +01:00
Niels Lohmann 7bb7033383 Merge branch 'develop' into coverity_scan 2017-02-01 16:03:51 +01:00
Niels Lohmann c75865d88c 🐛 fixed -Weffc++ warnings 2017-02-01 15:13:21 +01:00
Niels Lohmann b210f2dbf4 💄 minor refactoring 2017-01-29 21:40:37 +01:00
Niels Lohmann 0164b10e10 added missing tests found by mutate++ 2017-01-29 17:18:58 +01:00
Niels Lohmann affa3bf4e9 Merge pull request #439 from jaredgrubb/patch-2
README: adjust boost::optional example
2017-01-29 08:18:44 +01:00
Jared Grubb f2873e6d3a README: adjust boost::optional example
The "from_json" example for boost::optional is not complete and should also handle the 'none' case.
2017-01-29 02:46:58 +00:00
Niels Lohmann c7f366520c Merge branch 'develop' into coverity_scan 2017-01-28 18:43:48 +01:00
Niels Lohmann f642934b18 🔀 merge branch 'release/2.1.0' into develop 2017-01-28 18:43:01 +01:00
Niels Lohmann 1e99a0273f 🔀 merge branch 'release/2.1.0' 2017-01-28 18:42:27 +01:00
Niels Lohmann 6746a57524 📝 updated slides 2017-01-28 18:41:30 +01:00
Niels Lohmann eb08e8b09b 📝 updated documentation 2017-01-28 18:20:12 +01:00
Niels Lohmann 4b5c61075f 📄 changes to let Github detect the license 2017-01-28 18:17:57 +01:00
Niels Lohmann 38e4935db0 📝 added example and documentation for the meta function 2017-01-28 17:12:29 +01:00
Niels Lohmann cdde1a9436 🔖 set version to 2.1.0 2017-01-28 16:46:03 +01:00
Niels Lohmann d870826811 🔖 set version to 2.1.0 2017-01-28 16:03:35 +01:00
Niels Lohmann 2f6260751c 📝 fixed #434 2017-01-27 18:50:52 +01:00
Niels Lohmann 42fa3f0568 🔀 merge pull request #435 (based on #338, #355, and #423)
conversion from/to user-defined types
2017-01-27 06:22:10 +01:00
Niels Lohmann cd9701b123 💄 cleanup 2017-01-26 20:51:30 +01:00
Niels Lohmann 1305e03557 📝 fixed documentation 2017-01-26 19:39:34 +01:00
Niels Lohmann 77bb7af5d9 📝 added more documentation 2017-01-26 07:29:37 +01:00
Niels Lohmann 4d3053cd42 💄 some cleanup 2017-01-25 22:21:07 +01:00
Niels Lohmann 94d9b7bc86 📝 overworked documentation (re-added constructor examples) 2017-01-25 21:59:54 +01:00
Niels Lohmann ec03c9c53e 📝 overworked docs #435 2017-01-25 19:01:31 +01:00
Mihai STAN 6198439f59 fix #414 - comparing to 0 literal
Overload comparison operators for all types that could be converted
to nullptr.
2017-01-24 22:33:37 +02:00
Niels Lohmann 4139bb6572 📝 adjusted test count 2017-01-24 15:20:20 +01:00
Niels Lohmann c154f3133d 🚧 rephrased assertions 2017-01-24 15:02:35 +01:00
Niels Lohmann 50a3f3b301 📝 added nicer example 2017-01-24 14:55:51 +01:00
Niels Lohmann 781fd09f2d 📝 cleanup 2017-01-24 14:45:32 +01:00
Niels Lohmann daf8dcdb32 📝 overworked README 2017-01-24 14:37:25 +01:00
Niels Lohmann 250e5bf43d 💄 overworked documentation and indentation 2017-01-24 13:47:33 +01:00
Niels Lohmann 030cf674ef 🚧 fixed a warning 2017-01-24 12:49:38 +01:00
Niels Lohmann 3857e55290 💄 ran "make pretty" 2017-01-24 12:43:43 +01:00
Théo DELRIEU 9f103d19d7 add implicit conversions test (operator T()) 2017-01-22 14:23:24 +01:00
Théo DELRIEU 9f8b270ed9 fix some warnings 2017-01-22 14:07:28 +01:00
Théo DELRIEU 9c6ef74a28 add static_asserts/remove the need for CopyConstructible in get 2017-01-21 19:12:40 +01:00
Théo DELRIEU ba0b35f414 use typename U = uncvref_t where appropriate 2017-01-21 19:12:40 +01:00
Théo DELRIEU 37fd20b2eb put uncvref_t, enable_if_t, value_t and operator<(value_t) in detail 2017-01-21 19:12:40 +01:00
Théo DELRIEU 7d771c71ed put back type_name in basic_json
This can however not be done easily for value_t, since
external_constructor depends on it, as is operator< which was moved
outside basic_json too.
This is not really an issue, since all basic_json classes share the same
enum
2017-01-21 19:12:40 +01:00
Théo DELRIEU f997758cad remove useless forward declaration of primitive_iterator_t 2017-01-21 19:12:40 +01:00
Théo DELRIEU 40ba5a8b7b remove inline keyword from anonymous namespace (not needed) 2017-01-21 19:12:40 +01:00
Théo DELRIEU 7f359017d2 rename template argument Json -> BasicJsonType 2017-01-21 19:12:40 +01:00
Théo DELRIEU 708eb9613b disable reserve tests when exceptions are disabled 2017-01-21 19:12:40 +01:00
Théo DELRIEU 889b269a4f rename template argument: BasicJson -> Json 2017-01-21 16:14:23 +01:00
Théo DELRIEU a6b028286b move conjunction/disjunction to the top of detail 2017-01-21 16:14:23 +01:00
Théo DELRIEU d566bb81c4 use switchs where appropriate 2017-01-21 16:14:23 +01:00
Théo DELRIEU 1e20887cff use JSON_THROW 2017-01-21 16:14:22 +01:00
Théo DELRIEU 447c6a670f run make re2c 2017-01-21 16:14:22 +01:00
Théo DELRIEU 3e15b551e0 run make pretty 2017-01-21 16:14:22 +01:00
Théo DELRIEU fbac056c38 add readme 2017-01-21 16:14:22 +01:00
Théo DELRIEU b56117b148 add noexcept tests 2017-01-21 16:14:22 +01:00
Théo DELRIEU af94e712c7 add basic doxygen documentations 2017-01-21 16:14:22 +01:00
Théo DELRIEU 1d87097741 remove some boilerplate 2017-01-21 16:14:22 +01:00
Théo DELRIEU e60e458a7e move static_const to the detail namespace 2017-01-21 16:14:22 +01:00
Théo DELRIEU 794dae8911 apply changes to json.hpp.re2c 2017-01-21 16:14:22 +01:00
Théo DELRIEU 68081cd112 remove useless file 2017-01-21 16:14:22 +01:00
Théo DELRIEU 07bc82d3a7 put const to the left 2017-01-21 16:14:22 +01:00
Théo DELRIEU f1482d1f01 more tests in unit-udt 2017-01-21 16:14:22 +01:00
Théo DELRIEU f2c71fafda minor message/comments tweak 2017-01-21 16:14:22 +01:00
Théo DELRIEU 63e4249e9f use a priority_tag instead of int and longs with sfinae-dispatch 2017-01-21 16:14:22 +01:00
Théo DELRIEU b8012876a5 add noexcept checks, and some missing noexcepts 2017-01-21 16:14:22 +01:00
Théo DELRIEU 1554baa01d attempting to fix coverage. testing that reserve is called 2017-01-21 16:14:22 +01:00
Théo DELRIEU a9d5ae4fad put back a specialization for containers with a reserve method 2017-01-21 16:14:22 +01:00
Théo DELRIEU e247e01a6e use static_casts to silence MSVC warnings
Those warnings are not "fixed", but that's intentional.
Truncations are expected when ArithmeticType is not the same type than
number_unsigned_t (or another basic_json template argument)
2017-01-21 16:14:22 +01:00
Théo DELRIEU d0d8070422 add static_asserts
remove some useless trailing return types and && to help MSVC
2017-01-21 16:14:22 +01:00
Théo DELRIEU e678c075dd check for is_number_unsigned before is_number_integer 2017-01-21 16:14:22 +01:00
Théo DELRIEU cb3d455bd2 do not const_cast when calling get_ptr 2017-01-21 16:14:22 +01:00
Théo DELRIEU 3494014ba0 new unit-udt.cpp tests 2017-01-21 16:14:22 +01:00
Théo DELRIEU 1f25ec5d36 add some constexpr + noexcept 2017-01-21 16:14:22 +01:00
Théo DELRIEU 29f9fe6ae9 remove one has_to/from_json template parameter 2017-01-21 16:14:22 +01:00
Théo DELRIEU 5839795725 remove useless helpers 2017-01-21 16:14:22 +01:00
Théo DELRIEU b4cea6825d remove is_compatible_array_type_impl trait 2017-01-21 16:14:22 +01:00
Théo DELRIEU b2543e06d8 removed is_compatible_float_type trait 2017-01-21 16:14:22 +01:00
Théo DELRIEU be6b417c87 tweak SFINAE checks for internal types (see commit body)
only check for public types (iterators, json_pointer)

for private ones (m_array.iterator, primitive_iterator) simply double
parentheses on relevant Catch checks
2017-01-21 16:14:22 +01:00
Théo DELRIEU 317883b21b cleanup, details in body
removes:
- is_basic_json_compatible_type traits
- a useless operator=
- void_t
- disjunction

changes:
- is_compatible_object_type's first argument is BasicJson
2017-01-21 16:14:22 +01:00
Théo DELRIEU 4e8089b9de remove old get/get_impl overloads (doc removal is of course temporary) 2017-01-21 16:14:22 +01:00
Théo DELRIEU 7e6a6f978e replace constructor by from/to_json: array_t 2017-01-21 16:14:22 +01:00
Théo DELRIEU c847e0eea2 replace constructor by from/to_json: array_t
- tweaked a bit how `get<container<json>>` is handled
- added a from_json overload for forward list
2017-01-21 16:14:22 +01:00
Théo DELRIEU 6d427acdde replace constructor by from/to_json: unscoped enum types
this also means that one can do: j.get<unscoped_enum>();
2017-01-21 16:14:22 +01:00
Théo DELRIEU f00898331e replace constructor by from/to_json: number_integer_t 2017-01-21 16:14:22 +01:00
Théo DELRIEU a32de3b528 replace constructor by from/to_json: number_unsigned_t
This commit forces a design change in custom JSONSerializer, which might
be temporary
2017-01-21 16:14:21 +01:00
Théo DELRIEU d257149f36 replace constructor by from/to_json: number_float_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU bbe40641a3 replace constructor by from/to_json: string_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU 6b89785fba replace constructor by from/to_json: boolean_t 2017-01-21 16:14:21 +01:00
Théo DELRIEU c833b22b7b move type_name outside of basic_json, make it a friend 2017-01-21 16:14:21 +01:00
Théo DELRIEU d359684f2b move enum class value_t outside of basic_json 2017-01-21 16:14:21 +01:00
Niels Lohmann 034d5ed97e 💄 some cleanup 2017-01-21 16:14:21 +01:00
Niels Lohmann be1d3de49b 💄 moved changes to re2c file and ran make pretty 2017-01-21 16:14:21 +01:00
Théo DELRIEU aa2679a8ce fix tests, avoid instantiating JSONSerializer when it will not be used 2017-01-21 16:14:21 +01:00
Théo DELRIEU d5ee5830ed add more tests 2017-01-21 16:14:21 +01:00
Théo DELRIEU 1c21c87e6f use u8 prefix in unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU 7e750ec1fa fix msvc, by doubling parenthesis on catch assertions 2017-01-21 16:14:21 +01:00
Théo DELRIEU 3d405c6883 add support for enum classes 2017-01-21 16:14:21 +01:00
Théo DELRIEU 8e43d476d3 add more tests to unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU f5cb089f89 add an enum constructor (quickfix) 2017-01-21 16:14:21 +01:00
Théo DELRIEU 1eafac7220 remove explicit keyword on udt-constructor 2017-01-21 16:14:21 +01:00
Théo Delrieu c0c72b5b62 rewrite unit-udt: basic usage 2017-01-21 16:14:21 +01:00
Théo DELRIEU 60e6f822fa add support for non-default-constructible udt 2017-01-21 16:14:21 +01:00
Théo DELRIEU e5999c6c82 add a few tests 2017-01-21 16:14:21 +01:00
Théo Delrieu 74bb11d92c remove some useless checks, format a bit, added some comments 2017-01-21 16:14:21 +01:00
Théo DELRIEU 907484fb43 format biggest lines 2017-01-21 16:14:21 +01:00
Théo Delrieu 47bc402113 only use conjunction & co when needed to avoid MSVC crashing 2017-01-21 16:14:21 +01:00
Théo DELRIEU ee19acaf05 add is_compatible_basic_json_type trait 2017-01-21 16:14:21 +01:00
Théo Delrieu 9b401972a0 add a macro for has_xxx types 2017-01-21 16:14:21 +01:00
Théo DELRIEU e2dbe7a69f correctly constrain basic_json udt constructor 2017-01-21 16:14:21 +01:00
Théo DELRIEU 0d91113ccf add negation, disjunction, and conjunction from C++17 2017-01-21 16:14:21 +01:00
Théo DELRIEU 88819449c2 remove constraints on JSONSerializer instances, constrain correctly new methods 2017-01-21 16:14:21 +01:00
Théo DELRIEU 23bd2bce35 add is_compatible_* traits 2017-01-21 16:14:21 +01:00
Théo DELRIEU 178441cdfd add basic test for custom serializer 2017-01-21 16:14:21 +01:00
Théo DELRIEU 2bc685f6b4 to_json and from_json takes both two arguments now
the first is the basic_json type, the second the user-defined type
2017-01-21 16:14:21 +01:00
Théo DELRIEU 837b81d672 renamed unit-constructor3.cpp to unit-udt.cpp 2017-01-21 16:14:21 +01:00
Théo DELRIEU 33abccf847 add template arguments for JSONSerializer 2017-01-21 16:14:21 +01:00
Théo DELRIEU 7dc268ef42 add first version for alternate implementation 2017-01-21 16:14:21 +01:00
Théo DELRIEU 4cdc61e493 move most SFINAE trickery in to/from_json_fn 2017-01-21 16:14:21 +01:00
Théo DELRIEU 03b391c37b remove has_destructor and has_json_traits, use decltype instead 2017-01-21 16:14:21 +01:00
Théo DELRIEU 12b4555b13 use uncvref_t<T> instead of remove_cv_t<remove_reference_t<T>>> 2017-01-21 16:14:21 +01:00
Théo DELRIEU 877d96c1d8 rename __static_const to _static_const (reserved identifier) 2017-01-21 16:14:21 +01:00
Théo DELRIEU d54d6bb84c add alias templates to reduce boilerplate 2017-01-21 16:14:21 +01:00
Théo DELRIEU fe628b585b anonymous namespace renamed to detail 2017-01-21 16:14:21 +01:00
Théo Delrieu b443edf49e add first version support for user-defined types 2017-01-21 16:14:20 +01:00
Niels Lohmann ce0b3fe5a3 🚧 made type_name() public 2017-01-21 16:12:17 +01:00
Niels Lohmann 145188f264 renaming did not help 2017-01-19 19:23:56 +01:00
Niels Lohmann 69be3fa842 📝 small documentation update 2017-01-19 18:19:20 +01:00
Niels Lohmann 5e3f9c8969 📄 help Github find the license 2017-01-19 17:09:55 +01:00
Niels Lohmann e951d198f4 🔀 merge pull request #430 from vjon/patch-1
Fix documentation error
2017-01-19 07:42:29 +01:00
Jonathan Lee 046f6da82f Fix documentation error
Move comparison before "j.clear()" function call, such that the intended return value "true" is actually correct.
2017-01-18 11:43:14 -08:00
Niels Lohmann bae8e70137 🔀 merge branch 'feature/noexceptions_2' into develop 2017-01-18 20:41:17 +01:00
Niels Lohmann 87c5e32e1f 🐛 fixed escaping 2017-01-16 22:46:49 +01:00
Niels Lohmann a00149f8ee 🐛 fixed logic error 2017-01-16 22:36:58 +01:00
Niels Lohmann 1ab26ab367 option to switch off exceptions 2017-01-16 22:11:07 +01:00
Niels Lohmann 74cbd30cd0 📄 it's 2017 2017-01-16 20:04:47 +01:00
Niels Lohmann a7f3938391 added Big List of Naughty Strings 2017-01-16 20:03:50 +01:00
Niels Lohmann a9b4cb8bf8 🔀 merge branch 'feature/release_information' into develop #397 2017-01-12 21:37:31 +01:00
Niels Lohmann 3a9ccfac22 🚧 cleanup 2017-01-12 21:35:27 +01:00
Niels Lohmann 98ad3c3ac1 Merge branch 'develop' into feature/release_information 2017-01-12 21:30:08 +01:00
Niels Lohmann 0f03543861 ⬆️ upgraded to Catch 1.6.0 2017-01-11 22:23:02 +01:00
Niels Lohmann e9bbf5aaba 🐛 forgot to remove a test case 2017-01-08 09:31:40 +01:00
Niels Lohmann dd45ba6f89 🚧 renamed version() to meta() 2017-01-08 09:19:44 +01:00
Alex Astashyn c236b596c9 Merge upstream/develop into feature/locale_independent_str_to_num 2017-01-04 19:20:16 -05:00
Alex Astashyn 949061079a Merge upstream/develop into feature/locale_independent_num_to_str 2017-01-04 18:55:19 -05:00
Niels Lohmann e1b89dd1d6 Merge branch 'develop' into feature/release_information 2017-01-04 20:06:23 +01:00
Niels Lohmann 9f6c86f233 🐛 fix for #417 2017-01-04 18:54:44 +01:00
Niels Lohmann 4765070318 📝 added documentation wrt. UTF-8 strings #406 2017-01-04 18:07:46 +01:00
Niels Lohmann cdd3b5a68c 🚑 fix for #416 2017-01-03 23:52:01 +01:00
Niels Lohmann 767637877b 💄 cleanup 2017-01-03 22:37:07 +01:00
Niels Lohmann f8d640b185 👷 better support for OSS-Fuzz 2017-01-03 22:35:31 +01:00
Niels Lohmann 245a69d554 💄 ran clang-tidy 2017-01-03 21:33:23 +01:00
Niels Lohmann ea4d71ee21 Merge branch 'develop' into feature/release_information 2017-01-02 17:26:00 +01:00
Niels Lohmann 528bc96d7e Merge branch 'develop' 2017-01-02 16:41:33 +01:00
Niels Lohmann 0f36541d65 Merge branch 'develop' into coverity_scan 2017-01-02 16:39:52 +01:00
Niels Lohmann 9755cc75b1 🔀 merge branch 'release/2.0.10' into develop 2017-01-02 16:38:23 +01:00
Niels Lohmann 1c98ce869c 🔀 merge branch 'release/2.0.10' 2017-01-02 16:37:52 +01:00
Niels Lohmann 7e2c4b3ead 📝 updated online link 2017-01-02 16:37:29 +01:00
Niels Lohmann 69c615e127 🔖 version bump to 2.0.10 2017-01-02 10:00:44 +01:00
Niels Lohmann 4d3bf433b4 🔖 updated ChangeLog 2017-01-02 09:56:21 +01:00
Niels Lohmann 8b46eb8ec0 📄 it's 2017 already 2017-01-02 09:40:00 +01:00
Niels Lohmann 6a20790056 📝 updated test count 2017-01-02 09:36:30 +01:00
Niels Lohmann 60b3703c62 🔖 version bump to 2.0.10 2017-01-02 09:35:57 +01:00
Niels Lohmann d173517212 💄 clean up 2017-01-02 09:21:26 +01:00
Niels Lohmann a3063c2419 🚧 added target to build all fuzzers 2017-01-01 21:51:36 +01:00
Niels Lohmann db33629990 💄 cleanup after #410 2017-01-01 21:34:58 +01:00
Niels Lohmann 712529cd32 🔀 merge pull request #400 from andoma/develop
Add Doozer build badge
2017-01-01 19:47:33 +01:00
Niels Lohmann 09b91406c6 🔀 merge pull request #410 from Daniel599/feature/clang_sanitize
Feature/clang sanitize
2017-01-01 19:45:11 +01:00
Niels Lohmann ab7d55e7ae 👷 removed failing test suites 2017-01-01 19:38:54 +01:00
Niels Lohmann cf9bf2d913 🚑 fix for #411 and #412 2017-01-01 15:28:01 +01:00
Daniel Cohen ff3221a375 #394 fixed memory leak in unit-allocator, found by clang's fsanitize 2016-12-30 15:21:25 +02:00
Niels Lohmann 328eb55dc4 🚧 started working on #397 2016-12-30 14:02:51 +01:00
Daniel Cohen 010ea126f3 going to try clang_sanitize with libstdc++ with g++-6 implementation
Conflicts:
	.travis.yml
	Makefile
2016-12-30 14:24:22 +02:00
Niels Lohmann d7029c37aa improved test coverage 2016-12-30 13:04:33 +01:00
Niels Lohmann f7575dee94 Merge branch 'develop' into feature/release_information 2016-12-30 12:29:01 +01:00
Niels Lohmann 42a8c64499 🔖 added version information 2016-12-30 12:28:52 +01:00
Niels Lohmann f0edab2363 🚑 fix for #408 2016-12-29 17:00:02 +01:00
Niels Lohmann 383a29a924 🚑 fix for #407 2016-12-29 16:14:15 +01:00
Niels Lohmann 871cebaf84 🚑 fix for #405 2016-12-29 15:39:16 +01:00
Niels Lohmann 8381cd6020 🚑 removed unsafe call to strerror #403 2016-12-28 14:19:08 +01:00
Niels Lohmann e4c2829aea 🔀 merge branch 'feature/fuzzer' into develop 2016-12-28 12:26:00 +01:00
Niels Lohmann 1dd99d04b6 Merge branch 'develop' into feature/fuzzer 2016-12-28 12:19:12 +01:00
Niels Lohmann 888f5b9f60 🚚 renamed test files to allow windows build 2016-12-28 12:18:48 +01:00
Niels Lohmann 55be721615 Merge branch 'develop' into feature/fuzzer 2016-12-28 12:11:51 +01:00
Niels Lohmann acb7e0558d 🚑 fixed bugs detected by AFL-Fuzz 2016-12-28 12:09:15 +01:00
Niels Lohmann e3b036348b 🚧 added targets for parallel AFL fuzzing 2016-12-25 16:36:43 +01:00
Niels Lohmann 1399abc583 🚧 added MessagePack fuzz target 2016-12-25 16:18:56 +01:00
Niels Lohmann e4cc62e653 🐛 fixed Makefile to work with proper CBOR files 2016-12-25 16:07:10 +01:00
Niels Lohmann 6de9d4035a 🐛 fixed AFL driver to also read binary data 2016-12-25 16:06:56 +01:00
Niels Lohmann dbdcb3fec8 🐛 fixed bug in CBOR/MessagePack deserialization 2016-12-25 16:06:36 +01:00
Niels Lohmann 6e129fbfb7 📝 some small documentation fixes 2016-12-25 14:39:08 +01:00
Niels Lohmann f87f4c06f9 🚧 cleanup 2016-12-22 12:10:52 +01:00
Niels Lohmann 33be4e7f1f 🚧 cleanup 2016-12-22 12:08:36 +01:00
Niels Lohmann a084e90f39 🔨 split AFL test in driver and test file 2016-12-22 11:09:26 +01:00
Niels Lohmann 048330b14b ⬆️ Catch v1.5.9 2016-12-22 09:37:15 +01:00
Niels Lohmann 22a6b956e8 📄 added license for Catch 2016-12-22 09:36:34 +01:00
Niels Lohmann ad241a2260 🔨 moved third-party code into separate folder 2016-12-22 09:35:53 +01:00
Niels Lohmann 6e8791912f 🚧 added fuzzer from OSS-Fuzz 2016-12-22 09:09:40 +01:00
Niels Lohmann 69ed19e483 added libFuzzer 2016-12-22 09:08:50 +01:00
Niels Lohmann 09fd1a04b8 Merge branch 'develop' into coverity_scan 2016-12-21 16:19:26 +01:00
Niels Lohmann 7107072f71 👷 clang for fedora 2016-12-21 10:33:36 +01:00
Niels Lohmann 2cf0f299ad 👷 using clang where GCC is too old 2016-12-21 10:13:59 +01:00
Niels Lohmann 937cca762f 👷 forgot to install make 2016-12-21 09:54:11 +01:00
Niels Lohmann 91e45a8dd0 👷 the cmake of trusty is too old 2016-12-21 09:47:31 +01:00
Niels Lohmann f78671de8e 👷 Fedora has no package "build-essential" 2016-12-21 09:33:16 +01:00
Niels Lohmann 2e5208d5cd 👷 there is no cmake in the osx image 2016-12-21 09:19:53 +01:00
Niels Lohmann c6fbd305b0 👷 trying more doozer workers 2016-12-21 09:17:17 +01:00
Niels Lohmann 38597ac628 👷 added more builders 2016-12-20 23:04:07 +01:00
Andreas Smas 57b32d9773 Add Doozer build badge 2016-12-20 21:38:01 +01:00
Niels Lohmann 73b28e8f92 👷 fixing build command 2016-12-20 19:16:52 +01:00
Niels Lohmann 1178a8152a 👷 using cmake with Doozer 2016-12-20 19:13:19 +01:00
Niels Lohmann 0fffbb8488 👷 trying Doozer 2016-12-20 19:06:15 +01:00
Niels Lohmann ab64419bb6 Merge branch 'develop' into coverity_scan 2016-12-18 18:17:51 +01:00
Niels Lohmann 9952a3c456 👷 trying to fix coverity task 2016-12-18 18:17:26 +01:00
Niels Lohmann 03b78fee63 Merge branch 'develop' into coverity_scan 2016-12-16 21:42:34 +01:00
Niels Lohmann 0e55af23fc 🔀 Merge branch 'release/2.0.9' into develop 2016-12-16 21:35:28 +01:00
Niels Lohmann 6df60b0448 🔀 Merge branch 'release/2.0.9' 2016-12-16 21:34:54 +01:00
Niels Lohmann 57afd293aa 🔖 updated documentation 2016-12-16 21:34:37 +01:00
Niels Lohmann a507b9b46a 🔖 updated documentation 2016-12-16 21:25:20 +01:00
Niels Lohmann 36dc786106 🔖 updated Changelog 2016-12-16 21:09:14 +01:00
Niels Lohmann 706be50596 📝 updated number of tests 2016-12-16 20:54:43 +01:00
Niels Lohmann 303e873ae8 🔖 bumped version to 2.0.9 2016-12-16 20:45:46 +01:00
Niels Lohmann f6f7fed99a 🚨 removed some warnings 2016-12-16 18:57:19 +01:00
Niels Lohmann f24e4f680e 🎨 cleanup after PR #395 2016-12-14 22:30:09 +01:00
Niels Lohmann fe00b368ae 🔀 merge pull request #395 from Bosswestfalen/develop
Replace class iterator and const_iterator by using a single template class to reduce code.
2016-12-14 21:56:43 +01:00
Niels Lohmann 2f94c30bad added a regression test for #380 / #390 2016-12-13 21:46:07 +01:00
Niels Lohmann 4e2fb1a533 Merge pull request #390 from qwename/integer-overflow
🔀 fix issue #380: Signed integer overflow check
2016-12-13 21:26:53 +01:00
Niels Lohmann dfafd2c259 👷 can't get clang sanitizer to work #394
See https://travis-ci.org/nlohmann/json/jobs/183684093 for a failing
build.
2016-12-13 21:23:59 +01:00
Bosswestfalen 92e28c3153 added missing changes in json.hpp.re2c 2016-12-13 20:30:56 +01:00
Niels Lohmann c3fac19692 👷 another try for sanitizers #394 2016-12-13 19:41:36 +01:00
Niels Lohmann 3f089cab2b 👷 moved instructed build to "before_script" #394 2016-12-13 18:24:16 +01:00
Niels Lohmann 9b5411db57 👷 clang 3.9.0 is not working #394 2016-12-13 17:55:41 +01:00
Niels Lohmann f5d4a9c4eb 👷 added Clang 3.9.0 and sanitizer build #394 2016-12-13 17:51:46 +01:00
Yixin Zhang 703d4baf8b Fixed conversion warnings
Use static_cast on digit.
2016-12-12 21:12:08 -05:00
Yixin Zhang bd6422f583 Ran make pretty 2016-12-12 21:12:08 -05:00
Yixin Zhang 1e981115c9 Fix issue #380: Signed integer overflow check
Instead of checking something like `x * y + z > max` where `x * y` can
overflow, check for `x > (max - z) / y` instead.
2016-12-12 21:12:08 -05:00
Alex Astashyn 6fba52b6da Merged upstream/develop into feature/locale_independent_str_to_num 2016-12-12 20:27:15 -05:00
Alex Astashyn 5cad2006eb Tweaked check for preserved sign; added LCOV_EXCL_LINE 2016-12-12 20:15:57 -05:00
Alex Astashyn 65b9b0c429 Disabling snprintf pre-check, since can't get locale-specific behavior to manifest in AppVeyor 2016-12-12 19:50:21 -05:00
Alex Astashyn 0f8de48ddb Disabling strtod pre-check, since can't get locale-specific behavior to manifest in AppVeyor 2016-12-12 19:48:14 -05:00
Alex Astashyn cd0b651d43 Tweaked check for preserved sign; added LCOV_EXCL_LINE 2016-12-12 19:46:47 -05:00
Niels Lohmann 79fa8b2f41 🚑 fix to address #389 2016-12-12 23:19:43 +01:00
Bosswestfalen dd3f4f9b92 Replaced class iterator and class const_iterator with aliases of template <typename U> iter_impl. iter_impl has operator const_iterator to create an const_iterator from an iterator. 2016-12-12 19:26:45 +01:00
Niels Lohmann 447e01427d 🚨 fixed some warnings 2016-12-12 18:21:17 +01:00
Niels Lohmann b8776e8613 🚑 fix for #393 2016-12-12 17:39:56 +01:00
Niels Lohmann f6c21a1f20 📝 added note to example files 2016-12-12 08:25:08 +01:00
Niels Lohmann 5402458ff5 🚑 fixed an AddressSanitizer warning 2016-12-12 08:13:26 +01:00
Niels Lohmann a25d570040 📝 added TOC to README #383 2016-12-11 19:42:36 +01:00
Niels Lohmann ea7b40687b 📝 updated FAQ of the contribution guidelines #382 2016-12-11 16:36:39 +01:00
Niels Lohmann b2991950a5 📝 added not wrt re2c version #390 2016-12-11 16:21:53 +01:00
Niels Lohmann e906933f39 🔀 Merge branch 'feature/messagepack' into develop 2016-12-11 16:11:59 +01:00
Niels Lohmann a59eb4868a 🔀 Merge branch 'develop' into feature/messagepack 2016-12-11 16:11:43 +01:00
Niels Lohmann a9d7d315a5 📝 cleanup after #391 2016-12-11 16:06:52 +01:00
Niels Lohmann 446019aefd 🔀 merge pull request #391 from jaredgrubb/jgrubb-clang-doc-warning
Clang: quiet a warning
2016-12-11 16:04:27 +01:00
Niels Lohmann 6fa4f96ba3 📝 fixed two documentation warnings 2016-12-11 16:03:23 +01:00
Niels Lohmann dc6fc3e079 📝 clean up and added documentation for #358 2016-12-11 13:36:08 +01:00
Niels Lohmann fdce38fa79 fixed a test case 2016-12-11 00:39:26 +01:00
Niels Lohmann e8c903294f more test cases for CBOR and msgpack 2016-12-11 00:05:29 +01:00
Niels Lohmann 41673e8fed 🐛 fixed CBOR code and added test cases 2016-12-10 23:12:57 +01:00
Jared Grubb 98d6e6e523 Clang: quiet a warning 2016-12-10 13:19:56 -08:00
Niels Lohmann 7e5d6af5c1 🔨 refactored msgpack code 2016-12-10 21:30:18 +01:00
Niels Lohmann f1b95d78f9 🔨 refactored CBOR code to a switch 2016-12-10 19:29:45 +01:00
Niels Lohmann d99c230f51 implemented indefinite-length CBOR types (#387) 2016-12-10 18:32:56 +01:00
Alex Astashyn 01930357f7 Tweaking unit test, as digits grouping is failing to be invoked in CI 2016-12-08 22:39:38 -05:00
Alex Astashyn 343c9f9baa Addressing compiler warnings 2016-12-08 22:36:18 -05:00
Alex Astashyn 1c029b97c0 Still trying to invoke locale-specific behavior in CI 2016-12-08 22:13:05 -05:00
Alex Astashyn 38499e84fc Removed unused struct; fixed comments 2016-12-08 21:38:14 -05:00
Niels Lohmann 6b84c4155c 🔨 refactored get_from_vector function
Snippet from http://stackoverflow.com/a/41031865/266378
2016-12-08 09:37:23 +01:00
Alex Astashyn 50f0484ad5 Added unit test for issue #378 2016-12-07 20:23:25 -05:00
Alex Astashyn 27d9740ad6 Tweaks to unit-test for issue #379 2016-12-07 19:55:07 -05:00
Alex Astashyn 0a4a6a8399 Refactored to avoid using exceptions, as there are plans to support exceptionless mode 2016-12-07 19:53:27 -05:00
Niels Lohmann 81a4272444 more test cases for CBOR 2016-12-07 23:14:37 +01:00
Niels Lohmann 3a0f5398a2 more CBOR test cases 2016-12-07 22:50:10 +01:00
Niels Lohmann b7e0c12966 CBOR support for half-precision floats 2016-12-07 21:43:59 +01:00
Niels Lohmann 17c9b17a7e test cases from RFC 7049 #384 2016-12-07 21:25:22 +01:00
Niels Lohmann aab9bbbb93 🐛 fix for CBOR (small integers) 2016-12-07 21:24:42 +01:00
Niels Lohmann de289ea336 💚 another approach to the AppVeyor error 2016-12-07 19:15:05 +01:00
Niels Lohmann 81c43dca6a 💚 more AppVeyor fixes 2016-12-07 16:51:15 +01:00
Niels Lohmann 3f14a09e73 💚 another try to fix the AppVeyor build 2016-12-07 16:43:55 +01:00
Niels Lohmann 74571d531c 💚 still fixing the AppVeyor error 2016-12-07 16:34:02 +01:00
Niels Lohmann 2c7946f2bc 💚 hopefully fixed an error on AppVeyor 2016-12-07 16:21:22 +01:00
Niels Lohmann 8f6bfe5b32 🔨 refactored function to get numbers from byte vector 2016-12-07 14:47:06 +01:00
Niels Lohmann 474da6b28f :white_check_mark: more msgpack test cases 2016-12-07 13:47:08 +01:00
Niels Lohmann be973e52bb more msgpack test cases 2016-12-07 09:19:46 +01:00
Niels Lohmann a1693bfe48 Merge branch 'develop' into feature/messagepack 2016-12-07 08:39:57 +01:00
Alex Astashyn 6774457733 Trying to coerce setlocale to make snprintf use commas as delimiter some more 2016-12-06 22:59:12 -05:00
Alex Astashyn d169598c6c simplified code a bit based on @gregmarr's suggestions 2016-12-06 22:20:48 -05:00
Alex Astashyn d2e9ce270a Trying to coerce setlocale to make snprintf use commas as delimiter; the behavior appears to be compiler/platform-specific 2016-12-06 22:18:20 -05:00
Alex Astashyn 6e8da7d8c4 Added unit-test for issue #379 (locale-independent str-to-num) 2016-12-06 19:45:48 -05:00
Alex Astashyn 7a081244a5 Refactored preprocessing with a lambda instead of do{...}while(0) 2016-12-06 19:41:31 -05:00
Alex Astashyn 0c87d5d6b3 Refactored preprocessing with a lambda instead of do{...}while(0) 2016-12-06 19:41:05 -05:00
Alex Astashyn d643360575 Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale 2016-12-06 00:43:12 -05:00
Alex Astashyn 738d462955 Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale 2016-12-06 00:23:58 -05:00
Alex Astashyn 82b82fd487 Addressing msvc-specific compilation issues. 2016-12-05 20:33:28 -05:00
Alex Astashyn 509447b4d5 Small bufix related to creation of fmt string for snprintf 2016-12-05 19:03:39 -05:00
Alex Astashyn e41a956782 Alternative handling of integer types relying on strto[u]ll 2016-12-04 13:23:39 -05:00
Alex Astashyn 2197856395 Fixed suffixing .0 and modified the unit tests accordingly 2016-12-04 01:38:23 -05:00
Alex Astashyn 21cae35930 Added locale-independent numtostr 2016-12-04 01:27:22 -05:00
Alex Astashyn c75efedc6e stylistic changes 2016-12-03 23:19:43 -05:00
Alex Astashyn 4eafaab816 Improved overflow detection; removed debugging output statements. 2016-12-03 22:54:36 -05:00
Alex Astashyn 6b78b5c2be Added strtonum for locale-independent number parsing 2016-12-03 19:05:09 -05:00
Niels Lohmann f9a19af7a8 Merge branch 'develop' into coverity_scan 2016-12-02 20:30:20 +01:00
Niels Lohmann bc28942101 🔖 Merge branch 'release/2.0.8' into develop 2016-12-02 20:07:43 +01:00
Niels Lohmann 272ebdc900 🔖 Merge branch 'release/2.0.8' 2016-12-02 20:07:14 +01:00
Niels Lohmann 44c0f811b1 🔖 version 2.0.8 2016-12-02 20:05:53 +01:00
Niels Lohmann 6c24caf282 📝 updated ChangeLog 2016-12-02 19:04:36 +01:00
Niels Lohmann 4adb8a81bf 📝 version bump 2016-12-02 18:39:35 +01:00
Niels Lohmann 60b7299fe1 📝 updated README 2016-12-02 18:02:38 +01:00
Niels Lohmann 8f563a5f81 Merge branch 'feature/emplace' into develop 2016-12-01 21:22:23 +01:00
Niels Lohmann 5c811b91f1 Merge branch 'develop' into feature/emplace 2016-12-01 21:17:40 +01:00
Niels Lohmann ba3c5e1a25 more test cases 2016-11-29 09:49:05 +01:00
Niels Lohmann c46b4ea990 more test cases 2016-11-29 08:37:27 +01:00
Niels Lohmann e717492019 Merge branch 'feature/issue365' into develop 2016-11-29 07:46:14 +01:00
Niels Lohmann bd252b2a09 Merge branch 'develop' into feature/issue365 2016-11-28 23:24:52 +01:00
Niels Lohmann 50f647c866 Merge branch 'develop' into feature/messagepack 2016-11-28 23:24:35 +01:00
Niels Lohmann 7b6bd585c1 Merge branch 'develop' into feature/emplace 2016-11-28 23:23:56 +01:00
Niels Lohmann d563c21afe 📝 update documentation of Travis builders 2016-11-28 23:23:45 +01:00
Niels Lohmann ee0f23fdc6 🚧 bug fixes and more tests 2016-11-28 23:20:03 +01:00
Niels Lohmann 286025497f 👷 removed retired images (https://blog.travis-ci.com/2016-11-17-retiring-some-osx-images/) 2016-11-28 22:16:33 +01:00
Niels Lohmann aeb4f87a27 added return value for emplace (#349) 2016-11-28 18:33:46 +01:00
Niels Lohmann 6ecff31b7f Merge branch 'develop' into feature/emplace 2016-11-28 18:00:10 +01:00
Niels Lohmann bc238124ee 🚧 further simplifications 2016-11-27 21:42:21 +01:00
Niels Lohmann 4c232fe12b 👷 added precondition for individual tests 2016-11-27 19:11:58 +01:00
Niels Lohmann a820d688eb 🔨 refactored number-to-vector calls 2016-11-27 19:11:32 +01:00
Niels Lohmann 56843eb7ba Merge branch 'feature/individual_tests' into feature/messagepack 2016-11-27 18:28:23 +01:00
Niels Lohmann 93589e630c CBOR roundtrip tests 2016-11-27 17:47:56 +01:00
Niels Lohmann 2477b09cb9 🐛 Clang 3.9.0 seems to not work right now 2016-11-27 17:29:19 +01:00
Niels Lohmann f860f323be 🚧 falling back to single unit test for coveralls 2016-11-27 17:09:05 +01:00
Niels Lohmann 71c1232e32 🐛 fixed YAML 2016-11-27 16:46:33 +01:00
Niels Lohmann 36c79113fb 🚧 fixing coveralls and valgrind targets 2016-11-27 16:45:24 +01:00
Niels Lohmann e1f98fbfc0 🚧 splitting tests into several binaries 2016-11-27 16:19:26 +01:00
Niels Lohmann a73f43a7a2 🚧 CBOR support (#358) 2016-11-27 00:10:04 +01:00
Niels Lohmann eef408e5fb tests for CBOR 2016-11-27 00:09:24 +01:00
Niels Lohmann 87e088990b Merge branch 'develop' into feature/messagepack 2016-11-26 18:17:18 +01:00
Niels Lohmann a8522f391a Merge branch 'develop' into feature/issue365 2016-11-26 12:45:50 +01:00
Niels Lohmann 2773038cf9 added improvements (#365) 2016-11-26 12:43:23 +01:00
Niels Lohmann a791af30b4 Merge branch 'feature/filenotfound' into develop 2016-11-25 17:39:38 +01:00
Niels Lohmann 1ed510c232 Merge branch 'develop' into feature/filenotfound 2016-11-25 17:39:24 +01:00
Niels Lohmann f194db9aa6 added assertion for warning from #368 2016-11-24 22:07:35 +01:00
Niels Lohmann c39c36e6ad 💄 fixed indentation 2016-11-24 22:05:29 +01:00
Niels Lohmann 472d0045ba 📝 updating README after fixing #299 2016-11-24 21:56:21 +01:00
Niels Lohmann 1407bbf94c 💄 fixed indentation 2016-11-24 21:54:05 +01:00
Niels Lohmann 8014637ad1 added a test for EOF error (#367) 2016-11-24 21:53:41 +01:00
Niels Lohmann dfc49e7afe 🐛 fixed a bug if parser was called with a stream at EOF (#367) 2016-11-24 21:45:10 +01:00
Niels Lohmann 2819b555c8 Merge branch 'develop' into coverity_scan 2016-11-24 20:01:55 +01:00
Niels Lohmann 4bd3b1b0ef Merge branch 'develop' into feature/issue365 2016-11-24 18:25:00 +01:00
Niels Lohmann e3450cac72 📈 removing more variance of the benchmarks 2016-11-24 18:24:26 +01:00
Niels Lohmann c3a610d32a 🔧 ignoring Clion files 2016-11-24 17:45:01 +01:00
Niels Lohmann 739f8eefb7 Merge branch 'develop' into coverity_scan 2016-11-24 17:26:11 +01:00
Niels Lohmann 25548f85c9 👷 trying Coverity with Clang 3.6 (#299) 2016-11-24 17:25:05 +01:00
Niels Lohmann 4bb41d065b 🐛 parsing erroneous files yields an exception (#366) 2016-11-23 16:57:01 +01:00
Niels 5f4becb0f5 Merge branch 'develop' into feature/issue365 2016-11-23 08:48:54 +01:00
Niels ed611119d9 📈 reducing benchmark variance (#365) 2016-11-23 08:47:40 +01:00
Niels 6cc2d58d69 🐛 hopefully fixing the crashes on Linux (#365) 2016-11-22 20:13:47 +01:00
Niels f620d74919 added performance fixes (#365) 2016-11-22 07:26:11 +01:00
Niels 869f4c68d4 📝 updated thanks section 2016-11-22 07:25:40 +01:00
Niels c34b41acd6 🐛 fixes crash in dump from static object (#359)
Merge branch 'feature/issue359' into develop
2016-11-22 06:57:58 +01:00
Niels abce5c25bb 📝 cleaned comments and updated README 2016-11-21 23:38:17 +01:00
Niels 43dbe02d5b 🐛 fixing #359 2016-11-21 21:53:10 +01:00
Niels edc81f3bc1 💚 restored test call 2016-11-16 22:49:25 +01:00
Niels d362a07239 💚 moved sample.json to standard test suite to run it with Valgrind 2016-11-16 22:49:16 +01:00
Niels a9744f3937 💚 is sample.json killing AppVeyor? 2016-11-16 22:08:21 +01:00
Niels 0c9ab9427f 💚 added verbose message to check AppVeyor build 2016-11-16 22:02:38 +01:00
Niels 05e916717b Merge branch 'develop' into feature/messagepack 2016-11-16 19:16:36 +01:00
Niels 693bfe439b Merge branch 'develop' into feature/emplace 2016-11-16 19:16:16 +01:00
Niels 0d72767b3e ⬆️ updated to Catch v1.5.8 2016-11-16 19:15:54 +01:00
Niels 56667af823 🎨 stating the name of the library in the license 2016-11-16 19:08:25 +01:00
Niels 0a908ce8e2 Merge branch 'develop' into feature/messagepack 2016-11-16 09:04:37 +01:00
Niels b0f896558f Merge branch 'develop' into feature/emplace 2016-11-16 09:04:25 +01:00
Niels 425b9834a8 🐛 removed the wrong compiler 2016-11-16 08:25:08 +01:00
Niels 56671a88c6 🍎 removed Xcode 8.0 due to repeated problems 2016-11-16 08:01:48 +01:00
Niels 5316f0fff2 🍎 added Xcode 8.1 build for travis 2016-11-16 06:42:26 +01:00
Niels 1be73b903e proposal for emplace/emplace_back (#349) 2016-11-11 19:29:14 +01:00
Niels d1e73ce954 hid an expensive test case 2016-11-11 17:31:37 +01:00
Niels 543745a10e starting to integrate MessagePack (#358) 2016-11-11 17:11:13 +01:00
Niels 79a9d00e15 Merge branch 'develop' 2016-11-03 18:54:59 +01:00
Niels 9ca00e4880 readded missing header 2016-11-03 07:27:32 +01:00
Niels e385417047 documented and cleaned up headers (#314) 2016-11-02 21:27:19 +01:00
Niels 6d2b5e3771 Merge branch 'release/2.0.7' into develop 2016-11-02 20:52:42 +01:00
Niels a4d13c92ba Merge branch 'release/2.0.7' 2016-11-02 20:52:24 +01:00
Niels 700977d73e version bump 2016-11-02 20:52:15 +01:00
Niels 79015b9d0a Merge branch 'feature/jsontestsuite' into develop 2016-11-02 17:03:17 +01:00
Niels 3716a2fbe8 Merge branch 'develop' into feature/jsontestsuite 2016-11-02 17:03:12 +01:00
Niels 737d43724f Merge branch 'feature/issue329' into develop 2016-11-02 16:59:23 +01:00
Niels 59c8343851 cleanup 2016-11-02 15:44:46 +01:00
Niels 94c16b2c31 fixed coverage 2016-11-01 17:01:04 +01:00
Niels 8f70525374 more test coverage 2016-10-30 17:46:00 +01:00
Niels 7adccde714 improved coverage and updated README 2016-10-30 17:10:11 +01:00
Niels 8d1e65f297 evaluated i-tests (#344) 2016-10-30 16:07:17 +01:00
Niels 7b4e6cf705 added implementation-specific tests (#344) 2016-10-30 12:08:29 +01:00
Niels a8136c578a fixed BOM handling #344 2016-10-29 21:08:30 +02:00
Niels b820bb3b1f fixed a lot of unicode errors (#344)
BOMs currently yield an error.
2016-10-29 19:35:17 +02:00
Niels b03bbe724d added n test cases (#344) 2016-10-29 14:02:33 +02:00
Niels 7da182472d Merge branch 'develop' into feature/jsontestsuite 2016-10-29 13:37:17 +02:00
Niels 42ea4fb751 fixed a bug for short input files (#344)
For input files with less than 5 bytes, the parser had a bug so that
refilling the input buffer led to erasing it.
2016-10-29 13:32:36 +02:00
Niels 2fdba9de19 added "y" cases 2016-10-26 23:45:11 +02:00
Niels a2808322c6 add test files from https://github.com/nst/JSONTestSuite 2016-10-26 18:57:56 +02:00
Niels Lohmann a29fcae409 fixed Cmake link 2016-10-26 09:20:40 +02:00
Niels 3ebe28970a small fixes 2016-10-23 17:25:07 +02:00
Niels 79d9fdc016 user-defined string literals exploit string length (#340) 2016-10-22 18:57:58 +02:00
Niels e310850353 cleanup after #336 2016-10-16 23:46:24 +02:00
Niels Lohmann 8057782bb8 Merge pull request #336 from seeekr/patch-1
fix minor grammar/style issue in README.md
2016-10-16 23:40:17 +02:00
Denis Andrejew cb2d41e3a0 fix minor grammar/style issue in README.md 2016-10-16 02:46:43 +02:00
Niels 542a48a16a Merge branch 'release/2.0.6' into develop 2016-10-15 16:48:08 +02:00
Niels 60bba02cc6 Merge branch 'release/2.0.6' 2016-10-15 16:47:56 +02:00
Niels 606098f45d release 2.0.6 2016-10-15 16:47:45 +02:00
Niels d91067220f added missing overflow check for #329 2016-10-13 21:00:48 +02:00
Niels 67b9f1936d cleanup after closing #324 2016-10-12 22:05:45 +02:00
Niels Lohmann bb9d87ad55 Merge pull request #324 from vpetrigo/has_mapped_improve
make has_mapped_type struct friendly
2016-10-12 21:59:56 +02:00
Niels e7a60d8961 Merge branch 'feature/issue323' into develop 2016-10-12 21:21:59 +02:00
Niels 470197bd0b improve test coverage 2016-10-10 21:58:31 +02:00
Niels d3e7f9da67 code cleanup for #323 2016-10-10 20:38:50 +02:00
Niels 97280bbcfc added missing header 2016-10-09 16:32:01 +02:00
Vladimir Petrigo e9fde3e116 make has_mapped_type struct friendly 2016-10-08 16:50:23 +03:00
Niels 54bf5f20e9 adjusted README 2016-10-08 14:33:10 +02:00
Niels 2fa8ea0f74 started fixing #323 2016-10-08 14:27:28 +02:00
Niels a0ef5a194c addressed #319, #321, and #318 2016-10-06 23:27:43 +02:00
Niels Lohmann 04b11d78ff Merge pull request #318 from ChristophJud/include_dir_relocation
Include dir relocation
2016-10-06 22:35:36 +02:00
Niels Lohmann 8173c370f6 Merge pull request #321 from vasild/develop
Fix usage examples' comments for std::multiset
2016-10-06 22:33:58 +02:00
Niels b6550b35c3 fix after #313 2016-10-04 18:20:36 +02:00
Vasil Dimov b5128b1610 Fix usage examples' comments for std::multiset 2016-10-04 18:53:44 +03:00
Niels Lohmann 963efb1f09 Merge pull request #313 from 5tefan/develop
trivial documentation fix
2016-10-02 11:29:49 +02:00
Niels d6005e59a5 added fuzzing results 2016-10-02 11:23:47 +02:00
Christoph Jud e1b6a23049 relocation of install-include directory for other packages 2016-09-26 12:15:03 +02:00
Stefan Codrescu be61091401 trivial documentation fix 2016-09-16 18:15:36 -06:00
Niels e4366688f7 v2.0.5 2016-09-14 23:42:12 +02:00
Niels 5dfd2c9bdf Merge branch 'release/2.0.5' into develop 2016-09-14 23:07:14 +02:00
Niels 5879eb0be3 Merge branch 'release/2.0.5' 2016-09-14 23:06:53 +02:00
Niels 3d104f1d43 version bump 2016-09-14 23:06:39 +02:00
Niels 6bbcdc1ec5 fixes #310 2016-09-14 22:48:12 +02:00
Niels 7b6cba23f3 results for #307 2016-09-12 21:23:12 +02:00
Niels 24c588cd25 Merge branch 'release/2.0.4' into develop 2016-09-11 23:37:30 +02:00
Niels f209be1142 Merge branch 'release/2.0.4' 2016-09-11 23:37:11 +02:00
Niels 768d66560e version bump 2016-09-11 23:36:59 +02:00
Niels 15925469c6 Travis updated their Xcode 2016-09-11 22:50:40 +02:00
Niels f922426ec3 fixed #304 2016-09-11 22:40:51 +02:00
Niels 2daab5a4c2 fixed #306 2016-09-11 22:30:08 +02:00
Niels 8ea0ee502d clang 3.9.0 is not working yet 2016-09-03 13:08:17 +02:00
Niels fa0299f03a moved cmake into clang 2016-09-03 12:30:10 +02:00
Niels 36745ed296 install from tarball 2016-09-03 10:34:52 +02:00
Niels f0455b401d forgot sh call 2016-09-03 09:44:10 +02:00
Niels e0d809312b the cmake in apt is too old 2016-09-03 09:17:30 +02:00
Niels bfd6678800 clang 3.9.0 needs a newer cmake 2016-09-03 08:47:07 +02:00
Niels 9639f0dfb3 Clang 3.9.0 has been released 2016-09-03 00:37:45 +02:00
Niels 625370a1ad Merge branch 'develop' 2016-09-02 16:05:38 +02:00
Niels 357baeff5a release 2.0.3 2016-09-01 08:07:52 +02:00
Niels 42be2edd4c fixed test coverage 2016-09-01 00:29:42 +02:00
Niels c8d01fa7b9 Merge branch 'release/2.0.3' into develop 2016-08-31 21:27:50 +02:00
Niels 2c82f25272 Merge branch 'release/2.0.3' 2016-08-31 21:27:32 +02:00
Niels df9fd6237e release 2.0.3 2016-08-31 21:27:23 +02:00
Niels 776880bc49 Merge branch 'feature/iterator_range_parsing' into develop 2016-08-31 20:23:24 +02:00
Niels 740b66f225 cleanup 2016-08-31 20:23:21 +02:00
Niels 58cbf4b3ef added another test case 2016-08-31 18:23:46 +02:00
Niels ae7aaed4ac Merge branch 'develop' into feature/iterator_range_parsing 2016-08-31 18:07:18 +02:00
Niels 442058f8ed interface cleanup 2016-08-31 17:07:35 +02:00
Niels afba1d3fcb forgot to run re2c 2016-08-30 23:51:14 +02:00
Niels 941714c99c template changes did not work with MSVC 2016-08-30 23:49:06 +02:00
Niels a485aa8d27 cleanup and improvement of branch coverage 2016-08-30 23:44:15 +02:00
Niels 6e6e1c9b1f implemented idea from #290 2016-08-30 18:26:07 +02:00
Niels f76f9efe58 Merge branch 'develop' into feature/iterator_range_parsing 2016-08-30 18:20:13 +02:00
Niels Lohmann 463ffb21bc Merge pull request #300 from t-b/fix_warning_in_test_case
unit-constructor1.cpp: Fix floating point truncation warning
2016-08-29 22:52:18 +02:00
Niels 29c5f32d42 fixed performance degradation (#272) 2016-08-29 22:36:33 +02:00
Thomas Braun e0ff1a837c unit-constructor1.cpp: Fix floating point truncation warning 2016-08-25 00:24:33 +02:00
Niels Lohmann 87dea32e81 using AppVeyor badge for develop branch 2016-08-24 21:31:11 +02:00
Niels Lohmann bd3bd37e96 removed coverity badge (build is broken, see #299) 2016-08-24 21:29:28 +02:00
Niels 04c6c886eb another experiment 2016-08-24 21:02:33 +02:00
Niels Lohmann 8b833c452a experiment: changed order of parse functions 2016-08-24 07:12:56 +02:00
Niels 1d66ab9f7a fixed lexer issue which required null byte at the end of contiguous storage containers #290 2016-08-23 22:38:05 +02:00
Niels a79d634ccb integrated proposals for #290 2016-08-22 21:40:07 +02:00
Niels 6d1254baba Merge branch 'develop' into feature/iterator_range_parsing 2016-08-22 20:54:55 +02:00
Niels b688119aa4 reverted .travis file 2016-08-22 20:54:32 +02:00
Niels 29a4ef6c5c no execution for special cases 2016-08-22 20:50:12 +02:00
Niels 71af209ea9 fix for YAML file 2016-08-22 20:44:36 +02:00
Niels 79fd4dfbd8 do not build for special cases 2016-08-22 20:40:25 +02:00
Niels 8fbf635dd3 Merge branch 'develop' into coverity_scan 2016-08-21 23:20:05 +02:00
Niels cda84ba323 Merge branch 'develop' into feature/iterator_range_parsing 2016-08-21 23:15:27 +02:00
Niels 034244a291 Merge branch 'feature/coverage' into develop 2016-08-21 22:48:02 +02:00
Niels 1e896eb91e improved code coverage 2016-08-21 22:38:56 +02:00
Niels 94331a355d removed LCOV_EXCL_LINE 2016-08-21 21:50:13 +02:00
Niels aa7f5ad8b1 minor changes 2016-08-21 21:48:15 +02:00
Niels 585a39a235 improved branch coverage 2016-08-21 14:39:54 +02:00
Niels b4571360df more on #290 2016-08-21 12:35:40 +02:00
Niels eef8059003 allowing parsing from contiguous containers 2016-08-20 20:29:33 +02:00
Niels 6f3554f040 Merge branch 'develop' into feature/iterator_range_parsing 2016-08-20 18:51:11 +02:00
Niels 0cf7ebaa57 mentioning the CII 2016-08-18 18:43:27 +02:00
Niels d2564c6100 added cppcheck target for travis 2016-08-18 18:29:19 +02:00
Niels 039cedaf8e changes to address #295 2016-08-17 23:14:28 +02:00
Niels 628a5eae50 reset build file 2016-08-17 22:33:26 +02:00
Niels f40f81c87e forgot a semicolon 2016-08-17 21:44:53 +02:00
Niels c0922c7aac /Wall 2016-08-17 21:43:28 +02:00
Niels 35f22e8596 checking MSVC compiler flags 2016-08-17 21:38:19 +02:00
Niels a78eaa27b5 fixed unit tests 2016-08-17 21:31:59 +02:00
Niels 5e67f7af01 added a first version of a parser for #290 2016-08-15 22:44:14 +02:00
Niels f791c5fd2e Merge branch 'develop' into feature/iterator_range_parsing 2016-08-15 21:46:02 +02:00
Niels ca80a71c28 added notes from the CII Best Practices badge 2016-08-15 21:45:49 +02:00
Niels dfc2c1abe5 added assertion for contiguous memory 2016-08-14 23:38:20 +02:00
Niels 92ee1d56eb cleanup 2016-08-14 21:59:41 +02:00
Niels 4871e39415 spell fix 2016-08-14 17:52:21 +02:00
Niels 7b42c973bd fix for MSVC 2016-08-14 17:34:58 +02:00
Niels c9e5d56c9c fix for MSVC 2016-08-14 17:30:53 +02:00
Niels 01386b3977 cleanup 2016-08-14 17:23:15 +02:00
Niels b76f5506d7 added a parser for continguous containers 2016-08-14 14:18:25 +02:00
Niels 03de590372 improved documentation for #289 2016-08-11 20:52:48 +02:00
Niels 37fdcd893d Merge branch 'feature/travis' into develop 2016-08-10 22:50:11 +02:00
Niels 46174879ef clean up 2016-08-10 22:41:09 +02:00
Niels 5db41313ba valgrind + full unit tests takes too long 2016-08-10 21:33:03 +02:00
Niels 1c4ca6d7b1 rubygems -> ruby 2016-08-10 21:00:36 +02:00
Niels d02e67d4a9 coveralls with lcov 2016-08-10 20:56:26 +02:00
Niels ce30526ee8 fixed Valgrind call 2016-08-10 19:35:27 +02:00
Niels efe1d52629 added coverity, coveralls, and valgrind 2016-08-10 18:54:19 +02:00
Niels a2e923de32 removed clang 3.5.x 2016-08-10 18:38:31 +02:00
Niels 4d90331718 a test 2016-08-10 17:42:33 +02:00
Niels 997bc5d1ab more clang versions 2016-08-10 16:56:05 +02:00
Niels 31963723d3 no directory change 2016-08-10 16:35:57 +02:00
Niels 407e8dbb8e fixed YAML error 2016-08-10 16:25:35 +02:00
Niels b1c1fe9d39 added Clang 3.8 2016-08-10 16:22:53 +02:00
Niels b76861dde5 commit to re-fix issue #195 2016-08-09 23:05:42 +02:00
Niels 6150ffb9dc more compilers 2016-08-09 22:49:08 +02:00
Niels be05dbe618 moved sources 2016-08-09 22:33:31 +02:00
Niels 4b37082e36 more GCC versions 2016-08-09 22:29:01 +02:00
Niels 117fd59abd first try 2016-08-09 22:18:13 +02:00
Niels ff612e0e39 reverted last commit 2016-08-09 18:33:06 +02:00
Niels 0b34ddd47a another try for coveralls 2016-08-09 18:19:54 +02:00
Niels fa4fd334b2 accidentially deleted env 2016-08-05 08:56:58 +02:00
Niels d3c6ed08d6 set build-root 2016-08-05 08:40:42 +02:00
Niels 00046f6ff1 fix for coveralls 2016-08-05 08:18:19 +02:00
Niels 38f562af2a reorganization into smaller test units 2016-08-04 22:51:08 +02:00
Niels 2d3374c8b2 removed codecov 2016-08-04 22:10:30 +02:00
Niels bd75ef9f27 added check-fast flag 2016-08-04 22:05:16 +02:00
Niels ff592c6d50 adjusted warning flags 2016-08-04 22:05:05 +02:00
Niels 91b6e223d9 adjusted capacity test cases 2016-08-04 22:04:55 +02:00
Niels d80329034e split test suite in one file per test case 2016-08-04 21:55:47 +02:00
Niels 3944ecd470 chose correct flags 2016-08-04 07:40:04 +02:00
Niels be5cf0e3ba forgot to pass CPPFLAGS 2016-08-04 07:33:44 +02:00
Niels 5541e6f6f9 split unit tests 2016-08-04 07:24:46 +02:00
Niels 263e6af48d switch off assertions for benchmarks 2016-07-31 23:03:14 +02:00
Niels 4444ef9396 version bump 2016-07-31 14:39:15 +02:00
Niels c1a5a30285 Merge branch 'develop' into coverity_scan 2016-07-31 14:38:52 +02:00
Niels 9e67dc46fa Merge branch 'release/v2.0.2' into develop 2016-07-31 13:37:49 +02:00
Niels 3586767c05 Merge branch 'release/v2.0.2' 2016-07-31 13:37:26 +02:00
Niels a05df038cd prepared release 2016-07-31 13:37:04 +02:00
Niels 9e51c9041e replaced individual assertions by a class invariant function 2016-07-30 18:02:41 +02:00
Niels 891918a30f cleanup and documentation 2016-07-30 16:12:10 +02:00
Niels 5405ae8601 added default value 2016-07-30 10:50:53 +02:00
Niels b145e0c404 more cleanup 2016-07-29 23:47:16 +02:00
Niels b2b68a0fa1 header + cleanup 2016-07-29 22:24:47 +02:00
Niels 161c74a92e some cleanup 2016-07-28 21:19:56 +02:00
Niels 6297631e22 reverted breaking changes 2016-07-27 21:40:15 +02:00
Niels a7f8c47f68 cleaned up code
- removed unnecessary assertions
- simplified simple if/return patterns
2016-07-27 21:29:55 +02:00
Niels bdaade91f5 fixed some errors in the README gif 2016-07-27 17:07:00 +02:00
Niels 5e88c6f254 more on travis 2016-07-25 23:41:16 +02:00
Niels cc8102f0c4 used the wrong variable 2016-07-25 22:19:49 +02:00
Niels fd7c7be851 fixed bash errors 2016-07-25 19:38:51 +02:00
Niels 148fed1e63 minor change 2016-07-25 18:06:59 +02:00
Niels 02fc3cddee test homebrew on OSX 2016-07-25 16:48:26 +02:00
Niels a01ec918ac minor changes 2016-07-25 16:21:15 +02:00
Niels d08e013dd0 improved documentation 2016-07-25 16:06:13 +02:00
Niels 369671f028 added more Unicode tests 2016-07-25 16:05:58 +02:00
Niels dcea3a283c Merge branch 'feature/issue283' into develop (fixes #278) 2016-07-24 11:16:47 +02:00
Niels 84673b7de3 added test case from issue #283 2016-07-24 11:08:39 +02:00
Niels e2aa2d2189 improved test coverage 2016-07-24 11:01:47 +02:00
Niels 75dbbc55cf started to implement #283 2016-07-23 09:59:09 +02:00
Niels ddfe86cc49 fixed a bug that was found in the discussion of #274 2016-07-22 21:40:58 +02:00
Niels 51a3829680 reverted change to constexpr get_ref (does not work with GCC and MSVC) 2016-07-22 15:53:38 +02:00
Niels 4e7501e59a minor changes
- fixed a bug that did not discard strings with control characters
between 0x10 and 0x1f
- added termination proofs for two important loops
- made get_ref() constexpr
2016-07-22 15:34:45 +02:00
Niels 4c98c971b8 added benchmarks for numbers 2016-07-20 23:06:45 +02:00
Niels 5bab89fb22 Merge branch 'develop' into coverity_scan 2016-07-20 20:27:55 +02:00
Niels 1286d35767 make sure precision is reset on output streams during serialization 2016-07-20 20:07:45 +02:00
Niels ea19be1736 Merge branch 'develop' into coverity_scan 2016-07-19 22:49:17 +02:00
Niels cb145cfe71 updated Changelog 2016-07-19 22:43:56 +02:00
Niels 0f834056bb removed unused header 2016-07-19 22:17:43 +02:00
Niels 2478be807c avoid recursion in the scanner 2016-07-19 22:10:27 +02:00
Niels b64367e2f7 fix for #279 2016-07-18 16:22:10 +02:00
Niels 7f4dd5d608 added header for int64_t and uint64_t (fixes #282) 2016-07-15 19:44:19 +02:00
Niels 8116413106 Merge pull request #279 from murinicanor/patch-1
let the makefile choose the correct sed
2016-07-10 00:32:32 +02:00
Muri Nicanor 01f9ee5fd7 let the makefile choose the correct sed 2016-07-09 20:02:41 +02:00
Niels 98d48ef0c2 fixed indentation 2016-07-04 00:04:22 +02:00
Niels 71d20db4fc Merge branch 'feature/improved_documentation' into develop
- improved documentation
2016-07-01 18:02:37 +02:00
Niels c6d45c30d5 Merge branch 'feature/parser_performance' into develop
- improved parser performance by avoiding a copy of the result value
2016-07-01 17:44:27 +02:00
Niels 8f9f561742 Merge branch 'feature/detect_unsupported_compilers' into develop
- added error macros to exclude unsupported compilers
2016-07-01 17:42:36 +02:00
Niels 513fac589b Merge branch 'feature/algorithm_loops' into develop
- replaces some raw loops by std algorithms
- used std::advance where possible
2016-07-01 17:39:25 +02:00
Niels bd7cd330cd fixed type_name() signature 2016-07-01 17:26:09 +02:00
Niels 28644bada0 removed std::out output from test cases 2016-07-01 17:25:56 +02:00
Niels 05ddfaf5cf Merge branch 'develop' into feature/improved_documentation 2016-07-01 17:01:02 +02:00
Niels 6e1347e68c fixes #270 2016-07-01 16:58:50 +02:00
Niels 26cab42c38 some minor improvements 2016-07-01 16:52:05 +02:00
Niels 814fb31d64 Merge pull request #275 from dtoma/develop
Update hexify to use array lookup instead of ternary (#270)
2016-07-01 16:51:35 +02:00
Niels a5262c18e2 replaced a copy by a move to increase performance by 16-25% 2016-06-30 12:43:06 +02:00
dtoma 5c129c8981 Update hexify to use array lookup instead of ternary (#270) 2016-06-29 19:28:56 +08:00
Niels 52cbda8048 using std::advance where possible 2016-06-29 12:47:29 +02:00
Niels a0609b2da3 fixed coverage bug 2016-06-29 09:53:48 +02:00
Niels 924f78119b math... 2016-06-29 09:34:14 +02:00
Niels 7cb8ee42d5 wrong GCC version 2016-06-29 09:22:28 +02:00
Niels d456dec320 overlapping defines 2016-06-29 09:16:18 +02:00
Niels fc7f4b8fba replace some raw loops with algorithms 2016-06-28 22:49:05 +02:00
Niels dc479b3f9d check for unsupported compilers 2016-06-28 22:09:22 +02:00
Niels 7ffa07e3a3 update of ChangeLog 2016-06-28 21:46:53 +02:00
Niels d2475f9010 bumped version number 2016-06-28 21:44:03 +02:00
Niels 8b39570009 Merge branch 'develop' 2016-06-28 21:40:23 +02:00
Niels 3d4c79922e Merge branch 'release/2.0.1' into develop 2016-06-28 21:38:59 +02:00
Niels e29d6b5f41 Merge branch 'release/2.0.1' 2016-06-28 21:33:43 +02:00
Niels 026fe8041d adjusted Changelog 2016-06-28 21:33:34 +02:00
Niels a73bda8147 fixed performance regression #272 2016-06-28 21:24:18 +02:00
Niels 6a108bb84b Merge branch 'feature/issue272' into develop 2016-06-28 21:19:36 +02:00
Niels 7214243d89 reset locale (for #272) 2016-06-28 19:18:23 +02:00
Niels 420659f187 addressing #272 2016-06-28 10:42:17 +02:00
Niels 360f0f3791 updated README and ChangeLog 2016-06-24 17:39:03 +02:00
Niels c74b9ff4f7 another fix for the MSVC version 2016-06-24 17:15:54 +02:00
Niels a61231ad29 Merge pull request #271 from thelostt/patch-1
fixed a tiny typo
2016-06-24 11:28:01 +02:00
Mário Feroldi 6aad67af23 fixed a tiny typo 2016-06-24 05:47:00 -03:00
Niels 0767290c26 off-by-one error in the documentation 2016-06-24 08:06:41 +02:00
Niels ca2bbdb15b clarified MSV version 2016-06-24 07:39:08 +02:00
Niels 25ccf7f908 Merge branch 'release/2.0.0' 2016-06-24 00:46:36 +02:00
Niels 3c27678963 Merge branch 'develop' into coverity_scan 2016-06-24 00:28:10 +02:00
Niels 1c719561b0 update of documentation links 2016-06-24 00:14:27 +02:00
Niels b3cf45c8f5 updated release information 2016-06-23 23:34:41 +02:00
Niels 6542ae5766 fixed re2c warnings 2016-06-23 22:49:48 +02:00
Niels 0e90bcb539 Merge branch 'develop' into coverity_scan 2016-06-23 18:28:29 +02:00
Niels 39a9cfcc12 updated README 2016-06-23 18:08:20 +02:00
Niels f86fe57c18 Merge branch 'feature/undo-number-roundtrip' into develop 2016-06-23 18:00:06 +02:00
Niels 04a80a8f60 Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-23 05:57:41 +02:00
Niels 3497fab3b5 cleanup 2016-06-23 05:55:48 +02:00
Niels d14366c33e Merge branch 'feature/issue269' into develop 2016-06-23 00:05:01 +02:00
Niels 7cff6c8771 Merge branch 'develop' into feature/issue269
# Conflicts:
#	README.md
2016-06-23 00:04:55 +02:00
Niels 6f76c9237b overworked ChangeLog and README 2016-06-22 22:20:55 +02:00
Niels ecf84dddb1 test case for #269 2016-06-22 20:40:15 +02:00
Niels 59e67e768f fix for previous commit 2016-06-22 20:09:06 +02:00
Niels 3f97a5d5ad a conceptual quick fix for #269 2016-06-22 20:05:44 +02:00
Niels 804160e659 Merge branch 'develop' into coverity_scan 2016-06-19 22:39:05 +02:00
Niels 15a314abea updated README 2016-06-19 22:38:54 +02:00
Niels 0865ec87d4 re-added GCC6 2016-06-19 22:20:02 +02:00
Niels 3fe654e827 fix for coverity 2016-06-19 22:12:56 +02:00
Niels 3948021b6c Merge branch 'develop' into coverity_scan 2016-06-19 22:07:16 +02:00
Niels 20e4b20528 fix SSL issue with coverity 2016-06-19 21:57:32 +02:00
Niels 550475b5e1 Merge branch 'develop' into coverity_scan 2016-06-19 18:33:46 +02:00
Niels 90b46868b5 Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-19 18:27:07 +02:00
Niels 8c48ef1f73 updated to Catch v1.5.6 2016-06-19 18:25:43 +02:00
Niels b47fdf88ee Merge branch 'develop' into feature/undo-number-roundtrip 2016-06-19 17:59:53 +02:00
Niels 4ff27b207e fixed two typos 2016-06-19 17:56:58 +02:00
Niels ad7a419a03 removed roundtripping of floats (#230) 2016-06-19 17:13:13 +02:00
Niels 4e31a0e852 minor doc changes 2016-06-19 16:17:53 +02:00
Niels 039565b9f5 trying codecov 2016-06-18 14:33:29 +02:00
Niels bb8c7b1f45 mentioning Homebrew's --HEAD parameter 2016-06-15 21:28:27 +02:00
Niels 1eced269e3 update after PR #266 2016-06-14 15:27:21 +02:00
Niels 9eb86e1e12 Merge pull request #266 from 06needhamt/Issue
Fix Issue #265
2016-06-14 15:24:49 +02:00
Tom Needham fb90388af5 Fix Issue #265 2016-06-14 09:59:50 +01:00
Niels 39213bf34e Merge branch 'feature/issue260' into develop 2016-06-14 08:28:36 +02:00
Niels 44b210aa77 Merge branch 'develop' into feature/issue260 2016-06-14 08:23:09 +02:00
Niels c744d59f2d adjusted README file to reality in Travis 2016-06-14 08:14:25 +02:00
Niels 947db6ffe3 added Xcode 8 beta 2016-06-14 08:02:29 +02:00
Niels 494cc15650 Merge branch 'develop' into feature/issue260 2016-06-07 12:13:03 +02:00
Niels 48f69f40e7 enough for today... 2016-06-07 12:04:57 +02:00
Niels 97648314a4 setting explicit path to compiler 2016-06-07 11:52:12 +02:00
Niels 439563eb04 export 2016-06-07 11:42:34 +02:00
Niels 19be324f87 ? 2016-06-07 11:38:56 +02:00
Niels 3f23e70598 another try 2016-06-07 11:36:03 +02:00
Niels 62f39c41ec another try 2016-06-07 11:29:37 +02:00
Niels c425dc9e04 trying to install clang 2016-06-07 11:25:00 +02:00
Niels a4058b88ec another test 2016-06-07 11:14:02 +02:00
Niels ff8f196ca3 a test 2016-06-07 11:13:15 +02:00
Niels 31b24dd5c1 adding more Clang versions 2016-06-07 11:02:45 +02:00
Niels cc5cad5b0b another try 2016-06-07 10:53:18 +02:00
Niels 1f04c0349a readded -lc++ 2016-06-07 10:03:18 +02:00
Niels a97c998791 removed -lc++ 2016-06-07 09:50:43 +02:00
Niels 6d19bd1108 Revert "another try"
This reverts commit f63317dce3.
2016-06-07 09:49:11 +02:00
Niels f63317dce3 another try 2016-06-07 09:34:46 +02:00
Niels 32cc6fefcc another try 2016-06-07 09:12:53 +02:00
Niels fbbdcb19bc another try 2016-06-07 09:01:49 +02:00
Niels dd10c89a3e another try 2016-06-07 08:53:36 +02:00
Niels dd542aae7d another try 2016-06-07 08:40:25 +02:00
Niels 761880f5b7 CPATH does not work... 2016-06-07 08:32:56 +02:00
Niels 1826d12a22 added CPATH 2016-06-07 08:28:50 +02:00
Niels dfc39b95ab clang does not work with travis right now 2016-06-07 07:54:00 +02:00
Niels 32f6682177 another try 2016-06-07 07:25:11 +02:00
Niels f4ae8f8e2e another try 2016-06-07 07:21:17 +02:00
Niels e772f06f0d another try 2016-06-07 07:14:54 +02:00
Niels 5173c16222 another try 2016-06-07 07:07:42 +02:00
Niels 744bae7fc4 trying to fix Travis 2016-06-07 07:00:31 +02:00
Niels 9e2dfd19e8 minor cleanup 2016-06-07 00:20:53 +02:00
Niels b508d1f1c4 fix proposal for #260 2016-06-06 18:50:39 +02:00
Niels d4ff1bbaec Merge branch 'develop' into coverity_scan 2016-05-29 14:56:36 +02:00
Niels 04e1e7b586 cleanup 2016-05-29 14:56:08 +02:00
Niels 5666bd0e2d Merge branch 'develop' into coverity_scan 2016-05-29 14:06:54 +02:00
Niels aa8aa3ba9f overworked coverity stuffy 2016-05-29 14:06:43 +02:00
Niels 03db7b0dbb Merge branch 'develop' into coverity_scan 2016-05-29 13:32:48 +02:00
Niels 6bdb883b5c ignore build errors for coverity-scan 2016-05-29 13:32:36 +02:00
Niels 53603500ed Merge branch 'develop' into coverity_scan 2016-05-29 13:06:40 +02:00
Niels c0b2c6ea5d removing beta-xcode6.3 for now 2016-05-29 13:06:27 +02:00
Niels 97ea5ae403 Merge branch 'develop' into coverity_scan 2016-05-29 12:57:30 +02:00
Niels 6fed416125 fixed used compiler 2016-05-29 12:57:09 +02:00
Niels b26582c0e9 another try for coverity-scan 2016-05-29 12:29:46 +02:00
Niels 1cc77a5fe5 another try for coverity-scan 2016-05-29 12:15:13 +02:00
Niels 91dfc723be added coverity_scan 2016-05-29 12:07:20 +02:00
Niels 7bdfde4493 added a note about different NDKs (see #219) 2016-05-28 16:06:41 +02:00
Niels 71a7746ccb removed a line 2016-05-25 21:55:03 +02:00
Niels a3f432b3dd added hint to Homebrew 2016-05-18 22:23:35 +02:00
Niels 25d60b7bab Merge pull request #247 from robertmrk/feature/cmake-cleanup
Define CMake/CTest tests
2016-05-18 22:20:45 +02:00
Niels 837617122a fixed #246 2016-05-18 22:17:08 +02:00
Robert Marki 639d63217e Define CMake/CTest tests
Instead of copying the test executable and the JSON files used by
the tests at install time, define CMake/CTest tests for running
the json_unit executable from any build directory with the project's
source directory as its working directory.

- call enable_testing in the main lists file to allow the definition
of tests
- remove install commands from the test directory's lists file
- define two tests
  - json_unit_default for running the default tests by executing
json_unit without any arguments
  - json_unit_all for running all the tests by executing json_unit
with the "*" argument
- update the AppVeyor configuration file to use the new testing method
2016-05-18 11:53:49 +02:00
Niels 0a393b8374 indentation cleanup 2016-05-12 07:34:36 +02:00
Niels 0e0ecb2c14 fixed a warning and update ChangeLog 2016-05-12 00:32:18 +02:00
Niels fb06356856 thanks 2016-05-11 20:58:11 +02:00
Niels 888d022573 Merge pull request #242 from ChrisKitching/outOfTree
Out of tree builds and a few other miscellaneous CMake cleanups.
2016-05-11 20:52:45 +02:00
Niels f1e61896fb fixed a shadow error 2016-05-11 18:43:12 +02:00
Niels db5c9ec9ba fixed issue #239 (-Wconversion warnings) 2016-05-11 17:25:59 +02:00
Niels 91aa4c9def Merge branch 'develop' into feature/issue239 2016-05-11 17:23:01 +02:00
Chris Kitching 0e2f0c4edc Repair appveyor... Horrifyingly
It's sort of gnarly that it's still doing in-tree builds, but I
really, _really_ don't want to get any more friendly with CMake's
Visual Studio generator to work out how to make it stop doing it.

In-tree builds still work, after all, and the goal of this work is
to make out-of-tree builds work as well. Notional horrors like
this will have to wait ;)
2016-05-11 14:02:53 +01:00
Chris Kitching 527a69bb64 Install the test binary and test data. Fixes #241
The resulting install tree, when tests are enabled, looks like this:

```
.
├── cmake
│   ├── nlohmann_jsonConfig.cmake
│   ├── nlohmann_jsonConfigVersion.cmake
│   └── nlohmann_jsonTargets.cmake
├── include
│   └── nlohmann
│       └── json.hpp
└── test
    ├── bin
    │   └── json_unit
    └── data
        ├── json_nlohmann_tests
        │   ├── all_unicode.json
        │   └── bom.json
        ├── json.org
        │   ├── 1.json
        │   ├── ...
        ├── json_roundtrip
        │   ├── roundtrip01.json
        │   ├── roundtrip02.json
        │   └── ...
        ├── json_tests
        │   ├── fail10.json
        │   └── ...
        └── json_testsuite
            └── sample.json
```

It has the property that you can invoke the test binary from the
root of the install tree and the tests work correctly (you no
longer depend on the test binary being run inside the source
tree).

If tests are disabled, the entire `test/` subtree is omitted.
Notice how that yields exactly what you want for using this
library in other projects.

I do not believe I need to update travis due to this change, as the
evil Makefile continues to do in-tree builds. I expect I'll find
out soon enough.
2016-05-11 01:43:42 +01:00
Chris Kitching af76508fe7 Introduce structure to the test/ directory
This introduces a clear separation between test data and test
binaries. Test data is moved into test/data, and the test binaries
move into test/src. A new CMake script specific to building the
tests is introduced in /test to slightly clean up the toplevel
one.

As well as tidying things up, this makes the next step trivial...
2016-05-11 01:30:08 +01:00
Chris Kitching 4e6aacda36 Use definitely-unique target/project name
There exist lots of json libraries, and project/target names must
be globally unique. If someone integrated with this library in a
particularly stupid way, using a generic name like "json" might
cause a problem.
2016-05-11 01:14:56 +01:00
Chris Kitching b6becce8fb Don't use variable for the test target name
I'm not sure that using a variable for target names really helps
with clarity. Unlike paths, target names aren't really something
you change. In a sense, targets are themselves a sort of variable,
so having a variable to name a variable seems just a bit gnarly.
2016-05-11 01:12:56 +01:00
Chris Kitching bf7b6d15c7 Unset execute bit on sample.json 2016-05-11 01:10:29 +01:00
Chris Kitching 6a98a6c964 Add CMake option to disable building the tests (Default builds) 2016-05-11 01:06:32 +01:00
Niels 9ecf83f630 working on #235 2016-05-08 20:28:20 +02:00
Niels 6d8e00ade8 another try to remove a warning 2016-05-08 17:17:17 +02:00
Niels ac3036dc0f Merge branch 'develop' into feature/issue239 2016-05-08 17:07:08 +02:00
Niels fadf286653 added test case for std::bad_alloc 2016-05-08 14:35:32 +02:00
Niels 85a30813c8 removed unnecessary code (numbers must not begin with "+") 2016-05-07 20:22:58 +02:00
Niels 688cd49bdc Merge branch 'feature/json-patch' into develop 2016-05-07 18:41:02 +02:00
Niels c04275966f improved test coverage 2016-05-07 18:33:43 +02:00
Niels 9073b2ca39 hopefully removed some warnings 2016-04-30 16:22:27 +02:00
Niels ea84a85b13 simplified flatten/unflatten examples 2016-04-30 10:39:03 +02:00
Niels a21f8b0c77 added AppVeyor information 2016-04-30 01:21:35 +02:00
Niels 9170740f45 added documentation on Travis compilers 2016-04-30 01:01:41 +02:00
Niels 7c04bc3db6 added name call 2016-04-30 00:43:33 +02:00
Niels be16d005e4 get compiler versions 2016-04-30 00:25:11 +02:00
Niels f4ecceab19 cleanup 2016-04-30 00:12:19 +02:00
Niels 1d3b4dd158 added test cases 2016-04-30 00:03:47 +02:00
Niels 62f81a60d7 hopefully fixed a warning 2016-04-29 21:23:13 +02:00
Niels 82f5332cf4 Merge branch 'develop' into feature/json-patch 2016-04-29 20:50:34 +02:00
Niels 74544b42af removed MinGW compiler (too old) 2016-04-29 20:48:47 +02:00
Niels c019088d3b wrong MinGW binary 2016-04-29 20:35:40 +02:00
Niels b685737d53 added MinGW 2016-04-29 20:18:20 +02:00
Niels ddc5442c91 cleanup 2016-04-29 20:09:41 +02:00
Niels a07cdb14ec don't install valgrind for OSX 2016-04-29 20:01:11 +02:00
Niels 40abeb28d5 Valgrind only for Linux 2016-04-29 20:00:33 +02:00
Niels 68c50073a4 added OSX 2016-04-29 19:46:37 +02:00
Niels ca604c5a2e trying Clang 3.9 2016-04-29 19:37:52 +02:00
Niels 86d7e3090f removed GCC 6, added Clang 3.5 2016-04-29 19:33:43 +02:00
Niels e35805cf3a added GCC 6 and Clang 3.8 to Travis 2016-04-29 19:29:02 +02:00
Niels 86debab3b1 Merge branch 'develop' into feature/json-patch 2016-04-26 20:43:02 +02:00
Niels 9af8f7d094 update after #238 2016-04-26 20:38:01 +02:00
Niels 7dc07b75de Merge branch 'develop' into feature/json-patch 2016-04-26 20:32:24 +02:00
Niels 0f64761663 Merge pull request #238 from robertmrk/cmake-package
Implement additional integration options
2016-04-26 20:31:19 +02:00
Niels 5e0bf75d60 cleanup, test, and diff 2016-04-25 23:17:04 +02:00
Robert Marki 192a692034 Generate package config files in cmake's current binary directory
Generate the config files of the package in CMAKE_CURRENT_BINARY_DIR
instead of CMAKE_BINARY_DIR because the later will refer to the main
project's binary directory if the library is included in the project
using the add_subdirectory command.
2016-04-25 11:55:03 +02:00
Robert Marki b1a2e9a715 Create an install target for the project
- define the project's version in the cmake listfile
- create a config and config version file for the cmake package
- install the json.hpp file and the package's targets, config and
config version files
2016-04-25 10:27:19 +02:00
Robert Marki 30e396043a Export library target and store build directory in package registry 2016-04-25 09:36:05 +02:00
Robert Marki 28f73ed406 Refactor CMake listfile to define an interface imported library
Define the library as an interface imported library so other targets
can use the library as a dependency and use the interface properties
of the library.
2016-04-24 19:56:20 +02:00
Niels 96cfe7463f fixed some warnings 2016-04-24 19:09:12 +02:00
Niels 8d4cf5ef8d oops 2016-04-24 19:04:10 +02:00
Niels fb54e212b6 clean up and added tests 2016-04-24 19:03:33 +02:00
Niels 09e9f6dcd4 implemented "move" 2016-04-24 17:43:27 +02:00
Niels 855cf2307b extended "add" to cope with arrays 2016-04-24 16:51:06 +02:00
Niels 397ada22d3 implemented remove 2016-04-20 16:52:00 +02:00
Niels fa03cf0c63 replace and copy 2016-04-20 15:41:33 +02:00
Niels 70fc5835cb started implementing JSON Patch (RFC 6902) 2016-04-18 22:41:36 +02:00
Niels 3ca1bfdd9d made a function static 2016-04-17 23:41:52 +02:00
Niels f4107d0d9c updated documentation 2016-04-17 23:36:37 +02:00
Niels 9f8da4c650 Merge branch 'feature/json-pointer' into develop 2016-04-17 23:23:34 +02:00
Niels 08c97df420 added examples 2016-04-17 23:18:07 +02:00
Niels 1dee40a969 fixed test case 2016-04-17 22:34:39 +02:00
Niels 6268287940 improved documentation and test coverage 2016-04-17 22:08:21 +02:00
Niels 7034ae2486 improved test coverage 2016-04-17 19:12:12 +02:00
Niels 0835eb293f improved RFC compliance and code coverage 2016-04-17 18:54:54 +02:00
Niels f883a04c87 more documentation 2016-04-17 18:18:49 +02:00
Niels 40e899a819 cleanup and documentation 2016-04-17 17:39:35 +02:00
Niels f834965b44 implemented deflatten function 2016-04-16 20:45:40 +02:00
Niels 007359675b added a flatten function 2016-04-16 16:39:20 +02:00
Niels 3401954f5b cleaned up API 2016-04-16 14:02:14 +02:00
Niels 3a3e064287 Merge branch 'develop' into feature/json-pointer 2016-04-16 12:19:31 +02:00
Niels 76a5a776eb cleanup after #234 2016-04-16 12:19:10 +02:00
Niels 6f0053a254 Merge branch 'support-move-iterators' of https://github.com/robertmrk/json into develop 2016-04-16 12:12:16 +02:00
Niels 94af8abdff overworked reference token parsing 2016-04-13 23:23:54 +02:00
Niels 2cb925c186 adding support for escaped reference tokens 2016-04-13 17:41:19 +02:00
Robert Marki 2197f5f0a6 Make the indirection and dereference operators of iterator const
fixes #233
2016-04-13 13:49:53 +02:00
Niels 726051e9b7 very first draft of a JSON pointer API 2016-04-11 23:17:03 +02:00
Niels 507322e6f2 updated ChangeLog 2016-04-10 19:36:09 +02:00
Niels 15f8c848fa fixed typo and indentation 2016-04-10 18:23:43 +02:00
Niels 170b70f082 Merge pull request #232 from nlohmann/issue228
make serialization locale-independent (fixes #228)
2016-04-07 17:16:58 +02:00
Niels a744c62696 made tests independent of "C" locale 2016-04-05 22:28:27 +02:00
Niels 0b60d970e9 make code independent of concrete locale 2016-04-05 22:12:12 +02:00
Niels 31bccc83b9 fixed locale problems 2016-04-05 21:55:51 +02:00
Niels 43ee70cef8 revert changes to master 2016-04-05 20:47:47 +02:00
Niels 44a8e9bf35 locale-independent dump 2016-04-03 16:33:30 +02:00
Niels 9c233be567 merged #201 2016-04-03 14:08:38 +02:00
Niels 04edafbddc Merge pull request #227 from kevin--/kevin--/noexcept_documentation
fixes #223 by updating README.md
2016-03-30 20:21:35 +02:00
Niels 1baa5a7350 fixed #225 2016-03-30 20:18:34 +02:00
Niels 0951a1f94c Merge pull request #222 from Teemperor/fixAndroid
Added missing cerrno header to fix ERANGE compile error on android
2016-03-30 20:12:55 +02:00
Niels 96443b0b97 added more thanks to the README file 2016-03-30 19:47:08 +02:00
Niels 27530c7840 better notes for Android (manually closes #215) 2016-03-30 19:42:54 +02:00
Niels 888635b749 cleanup after PR #212 and PR #226 2016-03-30 19:23:11 +02:00
Kevin Dixon 3df5337e79 fixes #223 by updating README.md 2016-03-29 21:41:46 -07:00
Niels 54d3cab568 Merge pull request #226 from lv-zheng/fix_int64
Use namespace std for int64_t and uint64_t
2016-03-29 10:35:24 +02:00
Lv Zheng 3e76e61b9c Use namespace std for int64_t and uint64_t
According to the c++11 standard, the declarations are within namespace
scope of the namespace `std'. Add `std::' to avoid unnecessary
requirement of implementations.
2016-03-28 18:11:12 +08:00
Niels 2f63e5fb45 added copyright information to files to make release more self-contained 2016-03-25 17:41:36 +01:00
Raphael Isemann fbc25b080b Added missing cerrno header to fix ERANGE c-error on android 2016-03-10 08:46:26 +01:00
Niels c6a6a024f7 fixes #214 2016-03-06 20:03:05 +01:00
Niels 10a884473e fixed #217 2016-03-04 07:30:08 +01:00
Niels 8ee3d24046 Merge pull request #218 from Annihil/master
Corrected readme
2016-03-04 07:26:27 +01:00
Annihil 78a020354d Corrected readme
Internally, the elements in a map are always sorted by its key following a specific strict weak ordering criterion indicated by its internal comparison object (of type Compare).
With string type, the default comparator is alphabetical order, and thus two come after three.
2016-03-02 02:01:40 +01:00
Niels 53879f9c99 cleanup 2016-02-21 08:17:11 +01:00
Niels 502cedf70b Merge pull request #213 from whackashoe/patch-1
Create PULL_REQUEST_TEMPLATE.md
2016-02-21 08:15:46 +01:00
Jett LaRue df3ab06f2e Create PULL_REQUEST_TEMPLATE.md 2016-02-20 16:22:46 -06:00
Niels f965c4c35b improved code coverage 2016-02-14 22:56:51 +01:00
Niels d869b0a387 updated online documentation 2016-02-14 22:28:56 +01:00
Niels 3a92559fa9 cleanup 2016-02-14 22:24:45 +01:00
Niels 09654b3104 Merge pull request #208 from nlohmann/noexcept
fixed noexcept; added constexpr
2016-02-14 22:18:39 +01:00
Niels f160f33fb5 update from master 2016-02-14 21:44:00 +01:00
Niels 7f4736b546 added serialization to fuzz testing 2016-02-14 21:36:56 +01:00
Niels a3eecdc383 updated Catch to v1.3.4 2016-02-14 21:36:43 +01:00
Niels 153e105164 cleanup after #207 2016-02-14 18:38:29 +01:00
Niels ec098ffcc2 Merge pull request #207 from msm-/afl-fuzz
add support for afl-fuzz testing
2016-02-14 17:24:54 +01:00
Niels 49dc2dff68 fixed error when compiled with Clang 2016-02-14 16:58:24 +01:00
Niels 836fdfedf2 fixed an error in MSVC 2016-02-14 16:53:32 +01:00
Niels a69b1a6f0b added noexcept and constexpr 2016-02-14 16:42:48 +01:00
Michael Macnair 9e500b49ac Add support for afl-fuzz testing
"make fuzz" creates a simple executable that de-serialises stdin
and re-serialises to stdout.
"make fuzz_testcases" extracts the smaller json test cases into
a testcases directory.

The library can then be fuzzed as follows:
    CC=afl-clang-fast make fuzz
    make fuzz_testcases
    mkdir out
    afl-fuzz -i testcases -o out ./fuzz
2016-02-12 09:35:08 +00:00
Niels 61fe90f998 Merge pull request #205 from nlohmann/issue204
replaced ssize_t occurrences with auto (fixes #204)
2016-02-10 21:41:55 +01:00
Niels a831c787df try to replace std::ptrdiff_t with auto (for #204) 2016-02-10 21:19:31 +01:00
Niels 4cc4b26dd2 try to replace ssize_t occurrences with std::ptrdiff_t (for #204) 2016-02-10 21:09:52 +01:00
Niels 1cc4717582 tried Clang 3.9 2016-02-09 21:26:40 +01:00
Niels be20555985 removed gitter 2016-02-07 17:24:51 +01:00
Niels 236b7afff5 updated and fixed online version 2016-02-07 15:07:17 +01:00
Niels fdfb39d949 improved documentation 2016-02-07 14:55:29 +01:00
Niels 3b776c08c7 clarified documentation 2016-02-07 10:45:52 +01:00
Niels 8b1a777d36 reverted change wrt. Erasable concept 2016-02-05 22:37:28 +01:00
Niels 2ff2e10660 checking Erasable concept 2016-02-05 22:30:37 +01:00
Niels ae5bd307a2 improved documentation 2016-02-05 22:30:25 +01:00
Niels 2c720b26ab added a constructor from an input stream 2016-02-05 19:24:42 +01:00
Niels 104c4b5286 improve code coverage 2016-01-31 15:04:38 +01:00
Niels 6aa881988d improved documentation 2016-01-31 13:05:39 +01:00
Niels 22127a4b85 moved documentation to index markdown file 2016-01-30 22:05:01 +01:00
Niels 740239cef8 added a note about GCC 4.8 (#163) 2016-01-30 21:17:08 +01:00
Niels 36719fdb18 using re2c 0.16 (minimized automaton) 2016-01-30 20:33:31 +01:00
Niels 9d063d90e3 removed "using namespace" from examples 2016-01-30 20:23:14 +01:00
Niels ade2f7c92d updated ChangeLog 2016-01-30 16:51:53 +01:00
Niels 2224435f9b cleanup after #200 2016-01-30 13:36:15 +01:00
Niels cd44e43457 Merge pull request #200 from twelsby/issue199
Fixed issue #199 - Small bugs in json.hpp (get_number) and unit.cpp (non-standard integer type test)
2016-01-30 13:32:22 +01:00
Trevor Welsby 561accb068 Fixed issue #199 2016-01-30 12:41:12 +10:00
Niels ff6f723195 removed token 2016-01-26 23:30:51 +01:00
Niels 3dfa56795f added note 2016-01-26 23:27:07 +01:00
Niels 1c80c2231f linked releases in ChangeLog 2016-01-26 23:10:52 +01:00
Niels 89b07bd3af added (generated) changelog 2016-01-26 22:59:57 +01:00
Niels 91c58a77a1 added Gitter to Travis 2016-01-26 21:49:20 +01:00
Niels fb239fe645 trying Gitter 2016-01-26 21:42:51 +01:00
Niels 2468631dc9 overworked examples 2016-01-26 20:07:03 +01:00
Niels 707732a53e clean up after #193 2016-01-26 19:50:49 +01:00
Niels e46cc6327f Merge pull request #193 from twelsby/issue178
Issue #178 - Extending support to full uint64_t/int64_t range and unsigned type (updated)
2016-01-26 19:40:16 +01:00
Niels d338042e3e added note to warn about floating-point exceptions (#181) 2016-01-26 19:21:46 +01:00
Niels 11ae1d0f09 cleanup after #196 2016-01-26 19:13:03 +01:00
Niels 077fb1d540 Merge pull request #196 from twelsby/issue195
Issue #195 - update Travis to Trusty due to gcc/clang strtod() bug
2016-01-26 19:12:36 +01:00
Niels b630ce0e78 thanks 2016-01-26 19:11:58 +01:00
Niels 8deaabb289 Merge pull request #197 from m-click/fix_broken_link
Fix broken link
2016-01-26 19:10:46 +01:00
Volker Diels-Grabsch 08fd6dbf98 Fix broken link 2016-01-26 15:22:15 +01:00
Trevor Welsby 2de94365de Revert to llvm-toolchain-precise-* due to Travis white-list issue 2016-01-26 09:14:43 +10:00
Trevor Welsby a4a88b1b7d Issue #195 - update Travis to Trusty due to gcc/clang strtod() bug 2016-01-26 08:36:18 +10:00
Niels 2b13711009 updated online version 2016-01-24 23:02:28 +01:00
Niels c09d03fba7 fixed documentation 2016-01-24 22:43:00 +01:00
Niels 31093694ce fixed version number 2016-01-24 22:21:27 +01:00
Niels aee99b362d some editing 2016-01-24 19:24:06 +01:00
Trevor Welsby 0f28c69499 Merge upstream commits and resolve conflicts 2016-01-25 02:48:38 +10:00
Trevor Welsby 281492c581 Merge upstream commits and resolve conflicts 2016-01-25 02:42:20 +10:00
Niels 54a4139157 cleanup after #191 2016-01-24 17:33:46 +01:00
Trevor Welsby 4620960b72 Disable problematic test for GCC/clang, remove debug dump from unit.cpp 2016-01-25 02:22:46 +10:00
Niels ad5d1dabb2 Merge pull request #191 from twelsby/issue186
Fixed Issue #186 - add strto(f|d|ld) overload wrappers, "-0.0" special case and FP trailing zero
2016-01-24 17:21:22 +01:00
Trevor Welsby 81b7079255 Kill unused argument warnings in GCC/clang 2016-01-25 02:13:39 +10:00
Trevor Welsby 19918b948d Fix typo in preprocessor defined/!defined 2016-01-25 02:07:49 +10:00
Niels 9584a99a43 added issue stats 2016-01-24 17:06:36 +01:00
Trevor Welsby 421affd06e Merge upstream commits and resolve conflicts 2016-01-25 02:01:01 +10:00
Trevor Welsby 4d6985d4e2 Disable problematic test for GCC/clang, remove debug dump from unit.cpp 2016-01-25 01:53:32 +10:00
Niels dfb01c659b added more comments 2016-01-24 16:42:45 +01:00
Niels 3245a0dc06 fixed #194 2016-01-24 16:42:13 +01:00
Trevor Welsby 12ef668335 Merge upstream commits and resolve conflicts 2016-01-25 01:15:13 +10:00
Trevor Welsby d7ef2ccffd Issue #178 - fully support int64_t/uint64_t numbers, add unsigned type 2016-01-25 01:04:37 +10:00
Niels 8b6e0dc02d small addition 2016-01-24 13:28:16 +01:00
Niels d7d1e55648 applied include-what-you-use 2016-01-24 13:28:08 +01:00
Niels 8a0490a011 cleanup 2016-01-24 13:04:55 +01:00
Niels e00b00fea8 Merge pull request #190 from twelsby/issue185
fixed #185 - remove approx() and use #pragma to kill warnings
2016-01-24 12:55:40 +01:00
Niels 600ad330c5 cleanup after PR #189 2016-01-24 11:00:54 +01:00
Niels 21a44da89d Merge pull request #189 from twelsby/issue171
Fixed Issue #171 - added two extra template overloads of operator[] for T* arguments
2016-01-24 10:47:26 +01:00
Trevor Welsby f79d52b973 DEBUG ONLY: DUMP INFO FROM TRAVIS 2016-01-24 19:15:30 +10:00
Trevor Welsby c1f5f0451d Add workaround for gcc < 5 not supporting std::defaultfloat 2016-01-24 17:54:50 +10:00
Trevor Welsby bd8db5d40e Remove VS induced tabs 2016-01-24 17:15:44 +10:00
Trevor Welsby a1c6f16bd3 Fix Issue #186 - add overload wrappers for strto(f|d|ld) 2016-01-24 17:00:11 +10:00
Trevor Welsby 3a1403409f Issue #185 - remove approx() and use #pragma to kill warnings 2016-01-23 17:45:30 +10:00
Trevor Welsby bd0f3001c6 Fix typo in new unit.hpp comments 2016-01-23 17:31:58 +10:00
Trevor Welsby 7e3245786c Fixed issue #171 - added extra operator[] template overloads 2016-01-23 17:03:45 +10:00
Trevor Welsby 9de14a4861 Fixed issue #167 - removed operator ValueType() condition for VS2015 2016-01-23 16:34:15 +10:00
Niels f854410542 added a note wrt. Valgrind (#175) 2016-01-20 21:20:41 +01:00
Niels 5c4624c351 wishlist 2016-01-20 21:15:10 +01:00
Niels a04bd4f851 cleanup after #184 2016-01-20 21:14:58 +01:00
Niels 663ad13fc3 Merge pull request #184 from dariomt/master
Implementation of get_ref()
2016-01-20 20:58:44 +01:00
dariomt db3c7fdb96 added missing template keyword (required by clang) 2016-01-19 16:20:27 +01:00
dariomt e2f0e8b945 added missing typename (required by clang/gcc) 2016-01-19 14:56:07 +01:00
dariomt 4d079d135e replicate code changes into re2c file 2016-01-18 11:32:24 +01:00
dariomt e1645a09e9 Merge branch 'master' of https://github.com/nlohmann/json 2016-01-18 10:08:58 +01:00
Niels 72e33eec1a thanks 2016-01-15 08:24:44 +01:00
Niels 8968885c61 Merge pull request #182 from nibroc/master
Fixed some typos in CONTRIBUTING.md
2016-01-15 07:21:07 +01:00
Corbin Hughes 8ecccf8628 Fixed some typos in CONTRIBUTING.md 2016-01-14 22:36:39 -06:00
Niels c0bb5a56eb added note on assertions (#168) 2016-01-13 21:08:46 +01:00
Niels a05f27867b fixed wrong file name 2016-01-13 20:37:05 +01:00
Niels 832fe49bc1 fixed lists 2016-01-13 20:26:47 +01:00
Niels 57e018483a it's 2016 already... 2016-01-13 20:19:05 +01:00
Niels 1741e58eb5 contribution guidelines (#175) 2016-01-13 20:18:06 +01:00
Niels 4511145d3d removing unused catch variables (fixes #180) 2016-01-13 19:19:35 +01:00
Niels 151d43f63e fixing numerous typos (fixes #179) 2016-01-13 19:14:33 +01:00
Niels 4a452f11f9 added assertions (#168) 2016-01-03 17:05:27 +01:00
Niels d27c8a8ea8 reverting OSX 2016-01-02 16:49:56 +01:00
Niels fb7ff414ad more Valgrind information 2016-01-02 16:42:45 +01:00
Niels 2d48a36f5c trying Travis and OSX 2016-01-02 16:37:40 +01:00
Niels b4bb3afb65 removed clang 3.8 2016-01-02 15:42:56 +01:00
Niels 4a87ed4441 trying Clang 3.8 2016-01-02 15:34:34 +01:00
Niels 33abe87407 forgot version number 2016-01-02 15:30:12 +01:00
Niels dbf58ae9c0 trying to add Clang 3.7 toolchain 2016-01-02 15:24:13 +01:00
Niels 7614aa31c0 cleanup 2016-01-02 13:07:22 +01:00
Niels 9b07504e23 fix for #166 2016-01-01 18:33:58 +01:00
Niels 3905406f9c removed an unnecessary cast (fixed #162) 2015-12-29 12:30:05 +01:00
Niels aca6a3b373 version number 2015-12-28 15:04:15 +01:00
Niels cb5581392a preparing 1.0.0 release 2015-12-28 14:51:57 +01:00
Niels 80cdecaadd fixed a cppcheck warning 2015-12-27 18:07:21 +01:00
Niels d80bbffc78 minor cleanup 2015-12-27 17:58:36 +01:00
Niels 7371c71d2a using CHECK_THROWS_WITH to check exceptions (#160) 2015-12-27 15:30:30 +01:00
Niels d6b8830e03 more work on exceptions (#160) 2015-12-26 13:17:32 +01:00
Niels dc8ab92552 more tests for exceptions (#160) 2015-12-25 13:04:40 +01:00
Niels 76e5e29eda overworked exceptions and tests (#160) 2015-12-25 11:46:18 +01:00
Niels 8620583cf9 cleanup 2015-12-23 12:05:57 +01:00
Niels fcbd984e0f cleanup 2015-12-23 08:44:34 +01:00
Niels 70493a10d1 iterator_wrapper for const objects (#83) 2015-12-23 08:21:29 +01:00
Niels 00f9296db5 some cleanup for #83 2015-12-22 18:07:51 +01:00
Niels 67c2d90a21 working on #160 2015-12-22 13:27:40 +01:00
Niels 4351698c83 re-adding const version operator[] (#135, #159)
It was a good idea to implement a const version of operator[] it in the
first place. I was a pity that this implementation was flawed. It was a
mistake to remove the const version completely. This commit
re-introduces the const version. My apologies for all the inconvenience.
2015-12-21 08:42:42 +01:00
Niels 9def0186be upgraded Catch to v1.3.1 2015-12-20 15:42:01 +01:00
Niels 457bfc2401 work on #144 2015-12-20 15:30:07 +01:00
Niels 1adb9d62dd fixed #156 2015-12-17 16:52:38 +01:00
Niels ac4d4a0f66 fixed compilation error and fixed shadow warnings 2015-12-17 16:22:15 +01:00
Niels 07033f67a5 some cleanup and more documentation 2015-12-17 15:49:33 +01:00
Niels fb972e845b show reference to source code in documentation 2015-12-16 12:10:12 +01:00
Niels 6ac89df54d fix for #127 2015-12-16 12:09:59 +01:00
Niels a615598b14 cleanup documentation; started added versions 2015-12-15 19:42:32 +01:00
Niels 1df5d726d9 undid the fix for #136 2015-12-15 18:34:07 +01:00
Niels cd04a7d3e9 fix for #133
added value() function to get object value at given key or a default
value if key does not exist
2015-12-15 08:38:54 +01:00
Niels 2ba901bbf6 cleanup 2015-12-14 21:23:21 +01:00
Niels 5bc1b65676 clean up (for #154) 2015-12-14 16:58:49 +01:00
Niels 258f04c561 fixed #154 (no more warnings for incomplete switches) 2015-12-14 16:32:37 +01:00
Niels a70a7a8001 fixed #135: operator[] now only works on nonconst JSON objects 2015-12-13 11:26:55 +01:00
Niels c767f464bb dropped GCC 4.8 support (due to #110) 2015-12-08 18:12:34 +01:00
Niels 9da8770f3a ignore UTF-8 byte order mark (fixes #152) 2015-12-07 22:27:53 +01:00
Niels e0d334c4f1 added a comment (see #109) 2015-12-07 21:53:32 +01:00
Niels d6771ac79d corrected a username 2015-12-07 21:50:27 +01:00
Niels d9432aa168 Merge pull request #124 from emvivre/master
remove invalid parameter '-stdlib=libc++' in CMakeLists.txt
2015-12-07 21:11:58 +01:00
Niels 22bc022745 added change from #140 2015-12-07 21:05:21 +01:00
Niels 72476b4226 cleanup after #153 2015-12-07 20:38:16 +01:00
Niels f36f316fc7 Merge pull request #153 from whackashoe/remove_sprintf
Replace sprintf with hex function, this fixes #149
2015-12-07 20:35:43 +01:00
Niels 6f8e36ac3d fixes #136 2015-12-06 17:33:52 +01:00
Jett 14d8a91f73 Replace sprintf with hex function, this fixes #149 2015-11-19 00:30:00 -06:00
Niels c013223276 Merge pull request #146 from robertmrk/surrogate-pair-parsing-fix
Fix character skipping after a surrogate pair
2015-11-14 08:22:04 +01:00
Robert Marki ec7a1d8347 Fix character skipping after a surrogate pair
In a string the first character following a surrogate pair is skipped by the
lexer, but the rest of the string is parsed as usual.
2015-11-13 13:13:46 +01:00
Niels 3948630374 Merge pull request #130 from dariomt/patch-1
removed stream operator for iterator, resolution for #125
2015-10-23 18:42:10 +02:00
Niels 8f379ef3eb Merge pull request #137 from dariomt/patch-3
Detect correctly pointer-to-const
2015-10-20 22:31:15 +02:00
dariomt 652e1caa76 Apply same change to the re2c file 2015-10-19 12:34:10 +02:00
dariomt 8162a6e3a3 Apply same change to the re2c file 2015-10-19 12:26:38 +02:00
Niels 746c1a7142 cleanup 2015-10-17 12:51:59 +02:00
Niels 73632377bf Merge pull request #131 from dariomt/patch-2
disabled "CopyAssignable" test for MSVC in Debug mode, see #125
2015-10-17 12:41:20 +02:00
dariomt 4b8a822f33 Merge branch 'get_ref' 2015-10-16 16:42:03 +02:00
dariomt 95090a7ddd Merge branch 'patch-2' 2015-10-16 16:40:57 +02:00
dariomt 04cc7d5a05 doh! disable test correctly only for MSVC 2015-10-16 16:36:34 +02:00
dariomt 5198e1f2e4 removed const in get_ptr() by accident 2015-10-16 15:45:47 +02:00
dariomt bd2783f45c Added get_ref()
Same as get_ptr() but for references.
If the type is incompatible it throws (get_ptr() returns null).
Implemented in terms of get_ptr().
2015-10-16 15:23:57 +02:00
Dario Menendez 8f97e99feb Merge remote-tracking branch 'origin/patch-3' 2015-10-16 11:23:19 +02:00
Dario Menendez 8d53c5e06f Merge remote-tracking branch 'origin/patch-2' 2015-10-16 11:22:57 +02:00
dariomt b342e1207c Detect correctly pointer-to-const
The intention of the current code is to detect a pointer-to-const but instead it is detecting a const-pointer. See #134
2015-10-16 11:11:16 +02:00
dariomt 9d45aafc2c disabled "CopyAssignable" test for MSVC in Debug mode, see #125
STL iterators used by json::iterator don't pass this test in Debug mode.
The test does pass in Release mode, so I felt the best thing to do was selectively disable that test.
2015-10-07 18:31:08 +02:00
dariomt 55cbd903e8 removed stream operator for iterator, resolution for #125
It doesn't really make sense to stream an iterator.
Besides, this was causing trouble in MSVC in Debug mode (see #125)
2015-10-07 17:50:53 +02:00
Niels 57de1d602e Cleanup 2015-10-03 13:16:59 +02:00
Niels 2550d29ded Merge pull request #122 from d-frey/patch-1
exception-safe object creation, fixes #118
2015-10-03 12:29:26 +02:00
Niels 589dc2180a Merge pull request #120 from silverweed/patch-1
Overload parse() to accept an rvalue reference
2015-10-03 10:43:16 +02:00
Niels 4eac295211 Merge pull request #115 from whoshuu/patch-1
Use the right variable name in doc string
2015-10-03 10:41:26 +02:00
Niels b3ff862afc Merge pull request #121 from ColinH/master
Fix small oversight.
2015-10-03 10:39:14 +02:00
Niels 83d068c32c Merge pull request #126 from d-frey/patch-2
Remove superfluous inefficiency
2015-10-03 10:38:18 +02:00
Niels 99261bf39c Merge pull request #129 from dariomt/master
fixed typos in comments for examples
2015-10-03 10:36:35 +02:00
Dario Menendez 260745810d fixed typos in comments for examples 2015-10-02 15:57:40 +02:00
Daniel Frey 1c43789682 Remove superfluous inefficiency 2015-09-25 20:08:35 +02:00
emvivre 4f27004dd5 remove invalid parameter '-stdlib=libc++' in CMakeLists.txt 2015-09-22 16:57:18 +02:00
Daniel Frey f7fb405564 exception-safe object creation, fixes #118 2015-09-20 20:06:33 +02:00
Huu Nguyen 2d7f1542b1 Use the right variable name in doc string 2015-09-20 07:27:34 -07:00
silverweed 8fdd20cdda Overload parse() to accept an rvalue reference 2015-09-20 16:15:55 +02:00
Colin Hirsch c6c37d00d1 Fix small oversight. 2015-09-20 15:04:51 +02:00
Niels 0a81353989 reverted changes 2015-08-22 10:47:14 +02:00
Niels b9592bd2d6 more compilers 2015-08-22 10:43:04 +02:00
Niels 067e33a7ed removed failing compilers 2015-08-21 19:12:06 +02:00
Niels bb0d01e597 better compiler matrix 2015-08-21 19:05:47 +02:00
Niels 941c84e17d debugging 2015-08-14 15:30:06 +02:00
Niels 3c8c2766c1 debugging 2015-08-14 15:20:50 +02:00
Niels 23f70b47ad Appveyor fix 2015-08-14 15:09:16 +02:00
Niels bd5d96c456 minor change 2015-08-14 14:56:58 +02:00
Niels b58a93b8dd merged #111 2015-08-14 14:45:13 +02:00
Niels 6f2da1a39a try to avoid MSVC bug (https://connect.microsoft.com/VisualStudio/feedback/details/797682/c-decltype-of-class-member-access-incompletely-implemented) 2015-08-13 10:24:28 +02:00
Niels fadccc34eb fixed iterator_wrapper 2015-08-13 10:08:55 +02:00
Niels 66ec58639b removed failing tests 2015-08-06 23:02:52 +02:00
Niels 2707733920 fixed off-by-one error 2015-08-06 22:53:16 +02:00
Niels b0eb34394c added test cases for #83 2015-08-06 22:36:08 +02:00
Niels 11ae6da6d9 reverted “fix” for issue #107 2015-08-06 22:35:56 +02:00
Niels b431203fe8 fixed travis script 2015-08-06 21:33:24 +02:00
Niels 2c3259320d addressed locale-issues #107 2015-08-04 18:12:11 +02:00
Niels c910853304 fixed build 2015-08-02 21:49:42 +02:00
Niels b00e627c30 fixed build 2015-08-02 21:47:11 +02:00
Niels 9355dce063 fixed build 2015-08-02 21:40:25 +02:00
Niels e64dc532ab fixed build 2015-08-02 21:35:07 +02:00
Niels b5a05e1121 add a test for the iterator_wrapper 2015-08-02 21:27:02 +02:00
Niels c974e32677 fixed the build 2015-07-30 23:02:55 +02:00
Niels 8eb32084b4 code for #83 (no tests yet) 2015-07-30 21:32:18 +02:00
Niels a26e44d66e prepare 1.0.0-rc1 2015-07-26 20:44:55 +02:00
Niels 359cf7993f closed #75
minor changes, but the core idea remains the same
2015-07-26 18:41:58 +02:00
Niels c8ced4ecbc cleanup 2015-07-26 10:59:17 +02:00
Niels eb782770de removed Clang 3.7 2015-07-26 10:46:15 +02:00
Niels faac3c47c5 fixed travis 2015-07-26 10:41:49 +02:00
Niels 5993ff9976 updated catch 2015-07-26 10:41:38 +02:00
Niels 4c31de262e cleanup 2015-07-26 10:17:51 +02:00
Niels 77e6af0593 cleanup 2015-07-24 22:50:22 +02:00
Niels 0608e2d3e0 added g++-mingw-w64-i686 2015-07-24 22:43:00 +02:00
Niels d9a2077a0e only calculate coverage for GCC 4.9 2015-07-24 22:41:12 +02:00
Niels 3af829ef02 try 2015-07-24 22:29:03 +02:00
Niels 6a0be8b81c llvm source 2015-07-24 22:21:30 +02:00
Niels 9d01160ca8 cleaned llvm sources 2015-07-24 22:19:14 +02:00
Niels 004bb1e952 more llvm sources 2015-07-24 22:16:24 +02:00
Niels 82940483c3 sources for llvm 2015-07-24 22:14:16 +02:00
Niels 76bb61b544 set compiler flag 2015-07-24 22:11:09 +02:00
Niels 3b1c3fb77f added clang 2015-07-24 22:08:29 +02:00
Niels 48ad40607c fix for environment 2015-07-24 22:03:45 +02:00
Niels af5efeeff6 try env 2015-07-24 22:00:48 +02:00
Niels 56f1db2996 added CXX 2015-07-24 21:54:38 +02:00
Niels a4671428ca wrong sources 2015-07-24 21:52:56 +02:00
Niels 2ef7be5faf wrong sources 2015-07-24 21:51:01 +02:00
Niels 25293a4ca6 added missing source 2015-07-24 21:46:46 +02:00
Niels 276444113c local installation 2015-07-24 21:43:07 +02:00
Niels f5d2efdbd8 move to new Travis infrastructure 2015-07-24 21:41:07 +02:00
Niels 300fba6388 fixed Windows build 2015-07-19 13:33:03 +02:00
Niels 623c03bc49 some cleanup 2015-07-19 12:41:46 +02:00
Niels 818ae5a524 updated documentation to show off MSVC support 2015-07-16 22:37:54 +02:00
Niels 92fffaa872 cleanup 2015-07-16 19:53:42 +02:00
Niels afb17d7fac typo... 2015-07-16 19:39:18 +02:00
Niels c89ca716c5 switch off optimizations in MSVC 2015-07-16 19:32:19 +02:00
Niels a63c794521 some changes to Appveyor 2015-07-16 19:04:51 +02:00
Niels 5084159048 added changes from #105: MSVC fixes
- additionally, switch off optimization flags to maybe allow build to
complete on AppVeyor
2015-07-16 18:45:19 +02:00
Niels e007f02c54 updated readme 2015-07-14 21:24:29 +02:00
Niels 5c813b614f closes #104 and integrates code from #93
Iterators are now implemented via const_iterators and reverse_iterator
and const_reverse_iterator now share a template class. Thanks a lot!
2015-07-14 21:21:08 +02:00
Niels 1c8d5dc211 added another insert function 2015-07-12 22:47:08 +02:00
Niels 092bf39f53 added test case 2015-07-12 20:40:46 +02:00
Niels 186aefb8f2 added first insert functions 2015-07-12 18:28:23 +02:00
Niels b2efd50a03 more documentation 2015-07-12 17:08:51 +02:00
Niels 5e1d0f1592 more documentation and some cleanup 2015-07-12 14:49:37 +02:00
Niels c012b29ae5 worked on #102: more documentation and examples 2015-07-08 16:55:29 +02:00
Niels 19d550c044 new implementation for (const_)reverse_iterator to cope with issue #93 2015-07-07 23:31:43 +02:00
Niels 12d174d424 fixed #100 2015-07-06 23:21:54 +02:00
Niels e070aed8a7 cleanup 2015-07-06 21:12:50 +02:00
Niels 2bc5d893c8 refactored generic iterator into a new class primitive_iterator_t 2015-07-05 22:22:15 +02:00
Niels 82a6995306 fixed #101 2015-07-01 23:08:54 +02:00
Niels abd741708d more tests 2015-06-30 00:12:18 +02:00
Niels 55fe3807c9 small README fix 2015-06-29 23:20:33 +02:00
Niels 5ae2babf61 add online examples 2015-06-29 23:02:41 +02:00
Niels 540c58964d closed #91 2015-06-29 20:53:01 +02:00
Niels 48c4f4d05d more documentation 2015-06-28 19:32:09 +02:00
Niels 7d9cfb1b32 added documentation for erase functions 2015-06-28 15:49:40 +02:00
Niels 862e7000f4 fixed #94 2015-06-28 14:39:52 +02:00
Niels 3f6b10733b addressed static analysis warnings #94 2015-06-28 14:02:47 +02:00
Niels c58c5aa8c9 fixed #97
- added functions is_structured() and is_primitive()
- updated documentation
- updated test cases
2015-06-27 18:43:11 +02:00
Niels 3ffedea5c4 minor changes 2015-06-25 00:40:16 +02:00
Niels 5bad95f48e reset travis file 2015-06-24 23:08:40 +02:00
Niels aea2040d42 try travis matrix 2015-06-24 22:49:35 +02:00
Niels 6e6dd5f45d added test cases for the last uncovered lines 2015-06-24 15:46:50 +02:00
Niels 40312fb07b worked on #91
- implemented `get_ptr` function to return pointer to value member
- overworked `get` function to support pointer types
- added test cases
- added documentation (see
http://nlohmann.github.io/json/classnlohmann_1_1basic__json.html) with
examples
2015-06-24 15:16:32 +02:00
Niels 457572184c more documentation
In this commit, also the semantics for values skipped via the parser
callback has changed. Now, the top-level value is returned as “null”
instead of “discarded”.
2015-06-24 12:15:51 +02:00
Niels 48545f5b18 more documentation 2015-06-22 23:21:49 +02:00
Niels f1c9aa26c4 update Travis badge 2015-06-22 21:50:24 +02:00
Niels 844bfd39b5 more documentation 2015-06-22 21:44:20 +02:00
Niels 27b0a4d170 ... 2015-06-21 23:17:58 +02:00
Niels c43047e5f6 added codecov 2015-06-21 23:10:15 +02:00
Niels 88445fd96b fixed doxygen badge 2015-06-21 23:07:13 +02:00
Niels 8e97e46f50 update README badges 2015-06-21 23:05:50 +02:00
Niels 891b8f33c1 more documentation 2015-06-21 22:56:03 +02:00
Niels c85dbef98f more documentation 2015-06-21 22:42:32 +02:00
Niels 770b9820fe target to update documentation 2015-06-21 21:51:23 +02:00
Niels 91c330ae01 reorganized repo 2015-06-21 21:24:03 +02:00
Niels 4bb5126502 more documentation 2015-06-21 18:30:08 +02:00
Niels d972483b33 overworked documentation configuration 2015-06-21 13:39:10 +02:00
Niels f6040ea3bc minor change 2015-06-21 13:16:52 +02:00
Niels e0fa56f84f clean up 2015-06-21 13:14:39 +02:00
Niels 332b10998a clean up 2015-06-21 13:12:17 +02:00
Niels 099030baeb added alias __basic_json 2015-06-21 13:04:03 +02:00
Niels 022c11bf86 broke Makefile 2015-06-21 12:48:18 +02:00
Niels d200abfb5f automatic commit 2015-06-21 12:47:35 +02:00
Niels e289eada49 added target to update Doxygen 2015-06-21 12:45:46 +02:00
Niels 3a5b50d614 removed coverity_scan from travis file 2015-06-21 12:03:59 +02:00
Niels 0dd3ce742b forgot branch_pattern 2015-06-21 11:48:45 +02:00
Niels 3e28c5ff8f commit to trigger build 2015-06-21 11:35:54 +02:00
Niels d818bec6ac more documentation 2015-06-21 11:29:32 +02:00
Niels 70976e2b9c testing poverty 2015-06-21 11:29:24 +02:00
Niels c40e85920f more documentation 2015-06-21 09:44:12 +02:00
Niels bb13c931b3 more documentation 2015-06-21 02:14:01 +02:00
Niels e63c508172 overworked doxygen 2015-06-21 00:59:33 +02:00
Niels 0abac59291 mentioned Clang 3.7 2015-06-20 17:45:59 +02:00
Niels 4019380a8a forgot a header for MSVC 2015-06-20 17:45:52 +02:00
Niels 4fb825dbce fixed compiler warnings 2015-06-20 15:47:37 +02:00
Niels bd8150c58e updated Catch 2015-06-20 15:47:26 +02:00
Niels bf423363bd build in release mode on appveyor (from #88) 2015-06-20 15:13:45 +02:00
Niels 719cc9e4d7 removed dependent to RTTI 2015-06-20 14:57:08 +02:00
Niels 18cd30d38d minor iterator refactoring (from #88) 2015-06-20 14:29:34 +02:00
Niels 23c904aca8 added fix for ssize_t for MSVC 2015-06-20 14:25:49 +02:00
Niels 4f92731823 remove warnings on unit tests (from #88) 2015-06-20 14:16:57 +02:00
Niels 64c467e940 fix warnings possible loss of data (from #88) 2015-06-20 14:15:15 +02:00
Niels 29e8ca64bd applied a part of #88 2015-06-20 14:13:48 +02:00
Niels dd3ffc1064 fixed issue #93 2015-06-19 08:11:48 +02:00
Niels 51edad3962 fixed #89 without breaking #71 2015-06-15 19:45:25 +02:00
Niels 8e9a711996 closes #90 2015-06-15 16:37:49 +02:00
Niels 1375162562 exclude Unicode tests from Valgrind to avoid timeout 2015-06-15 05:46:12 +02:00
Niels 2e9a13bd88 added extensive Unicode tests 2015-06-14 23:17:49 +02:00
Niels 6fb829062c some maintenance
- unified used exception types
- removed any camel case names
2015-06-14 19:35:20 +02:00
Niels bc55e496de test suite is not portable :-( 2015-06-13 13:01:10 +02:00
Niels bd0cb65b7a fixed more float parsing cases 2015-06-13 12:42:18 +02:00
Niels 7c579f11e5 some cleanup after #87 2015-06-13 10:29:43 +02:00
Niels a8339894b2 Merge pull request #87 from ahamez/master
Keyword 'inline' is useless when member functions are defined in headers
2015-06-13 10:27:24 +02:00
Alexandre Hamez a8aced74bc inline is useless when member functions are defined in headers
See https://isocpp.org/wiki/faq/inline-functions#inline-member-fns-more
2015-06-12 10:08:57 +02:00
Niels 7f25511242 change from #86 2015-06-11 18:10:12 +02:00
Niels bab7e9667f added badge for license 2015-06-11 18:08:00 +02:00
Niels 6d8a4aea98 Merge pull request #86 from ahamez/master
Remove useless typename
2015-06-11 18:01:06 +02:00
Alexandre Hamez 41e9e000bf Remove useless typename
Avoid a warning with GCC 4.9:

son.hpp:2361:49: warning: declaration 'struct std::bidirectional_iterator_tag' does not declare anything
         using iterator_category = typename std::bidirectional_iterator_tag;
                                                 ^
2015-06-09 13:31:10 +02:00
Niels 2d26d85c2b some cleanup 2015-06-08 16:35:38 +02:00
Niels d3b0f207b0 Merge pull request #85 from ahamez/master
Avoid warning with Xcode's clang
2015-06-08 16:32:37 +02:00
Alexandre Hamez f17733b859 Directly return ostream 2015-06-08 11:39:32 +02:00
Alexandre Hamez c49d83172f Avoid warning with Xcode's clang 2015-06-08 11:38:52 +02:00
Niels adc065d328 included fixes for MSVC (see #62)
94de11e, f673c8d, 540b763
2015-06-04 21:02:16 +02:00
Niels 29512ae989 added test case for #82 2015-06-04 20:07:33 +02:00
Niels b8d05f72ea fixed float serialization (#81 and #80) 2015-06-04 19:43:29 +02:00
Niels 266399d8e5 fixed MinGW compilation (#81 and #80) 2015-06-04 08:31:13 +02:00
Niels 5f4fd0b6a2 reset 2015-06-03 23:44:45 +02:00
Niels 9dbb4402fb improved performance for dump() 2015-06-03 23:34:10 +02:00
Niels cb873a42ed added Benchpress benchmarks 2015-06-02 23:57:45 +02:00
Niels f5470d47ff made array static constexpr (#79) 2015-06-02 21:27:49 +02:00
Niels afc7f2388e fixed typo (#74) 2015-06-02 21:24:03 +02:00
Niels e2035df957 added unit test for issue #76 2015-05-30 16:47:21 +02:00
Niels 58d7342be7 Merge pull request #73 from maqnouch/patch-1
Fix typos
2015-05-12 17:29:50 +02:00
AQNOUCH Mohammed 7da56cf292 Fix typos 2015-05-12 14:59:44 +01:00
Niels 61f0376366 more cleanup 2015-05-10 17:30:41 +02:00
Niels cb2102a2d2 some pretty-printing 2015-05-10 17:12:36 +02:00
Niels 072dc25521 Merge pull request #72 from aburgh/null-callback
Replace `default_callback` function with `nullptr` and check for null…
2015-05-10 17:10:47 +02:00
Niels 43ededf41f more cleanup 2015-05-10 17:03:50 +02:00
Aaron Burghardt ef54ace4d2 Replace default_callback function with nullptr and check for null callback function before calling it. This is cleaner and better performing. 2015-05-10 10:32:49 -04:00
Niels 76d3433e6c moved some code to json_value union 2015-05-10 16:30:33 +02:00
Niels 5ed80d308d some parsing performance improvements 2015-05-09 22:49:21 +02:00
Niels abb8653115 more test cases 2015-05-09 16:58:06 +02:00
Niels 03634cacbc cleanup 2015-05-09 15:38:58 +02:00
Niels 165d367493 updated README 2015-05-09 15:30:17 +02:00
Niels 9cdd278f45 overworked code for pull request #71 2015-05-09 15:29:20 +02:00
Niels aca3f65bbe Merge pull request #71 from likebeta/master
support enum
2015-05-09 15:23:51 +02:00
Niels 2b4e461702 fixed string definition 2015-05-09 15:09:52 +02:00
Niels 1f381d496d overworked coverage 2015-05-09 14:54:33 +02:00
Niels bb142d6cae added test cases 2015-05-09 14:37:22 +02:00
Niels 869035a6c9 added compliance test cases 2015-05-09 13:56:51 +02:00
易思龙 91aee10579 support enum
construct enum type to basic_json (proxy by int type)
```
    enum { t = 0 };
    json  j = json::array();
    j.push_back(t);

    j.push_back(json::object({
         {"game_type", t}
    }));
```
2015-05-09 17:44:10 +08:00
Niels 9f9d293bad valgrind still makes problems 2015-05-06 21:32:41 +02:00
Niels b67b13c29e Appveyor 2015-05-06 20:48:20 +02:00
Niels bef256600c added test cases 2015-05-06 20:46:04 +02:00
Niels 2cfc93fc76 overflows are handled wrong by Valgrind 2015-05-06 20:21:06 +02:00
Niels a8e92a6bfb fixed #68 2015-05-06 20:18:16 +02:00
Niels 17609f244d fixed #70 2015-05-06 19:52:12 +02:00
Niels 1580eee4ed applied #69 to header 2015-05-04 23:31:34 +02:00
Niels 723155a30a Merge pull request #69 from aburgh/callback_performance
Fix performance regression introduced with the parsing callback feature.
2015-05-04 15:39:44 +02:00
Aaron Burghardt ea3e922a12 Fix performance regression introduced with the parsing callback feature. 2015-05-04 09:08:55 -04:00
Niels 2b825760b5 removed failing test case 2015-05-03 21:37:14 +02:00
Niels 07dd3af848 another try 2015-05-03 21:28:57 +02:00
Niels 370929ac08 overworked test case 2015-05-03 21:10:22 +02:00
Niels c458bf18e6 more test cases 2015-05-03 20:59:11 +02:00
Niels 106705ed73 more tests 2015-05-03 20:42:24 +02:00
Niels 10bbb77491 test case for filter function 2015-05-03 20:18:16 +02:00
Niels 1143094e4c testing the callback function 2015-05-03 20:07:31 +02:00
Niels 093b97efc4 more tests 2015-05-03 19:55:45 +02:00
Niels f66e603686 more test cases 2015-05-03 18:59:58 +02:00
Niels 1ac4d673b6 fixed test case 2015-05-03 18:46:26 +02:00
Niels ab1ff9de53 added more test cases 2015-05-03 18:27:43 +02:00
Niels 84561d8866 improved test case coverage 2015-05-03 18:19:12 +02:00
Niels 952cbbc795 manually merged pull request #41 2015-05-03 17:52:13 +02:00
Niels faae8bb843 some typename fix 2015-04-27 23:09:51 +02:00
Niels 14e54b2b72 Appveyor 2015-04-27 22:53:46 +02:00
Niels ecc97bcf96 added /EHsc parameter 2015-04-27 22:45:21 +02:00
Niels 1068ad106b fixed Makefile 2015-04-27 22:35:45 +02:00
Niels e7da0b4b7c Appveyor 2015-04-26 23:56:42 +02:00
Niels 0c0a462c28 Appveyor 2015-04-26 23:47:11 +02:00
Niels 257bf46133 Appveyor 2015-04-26 23:41:11 +02:00
Niels c16ee07601 Appveyor 2015-04-26 23:31:22 +02:00
Niels 35485c05e3 Appveyor 2015-04-26 23:21:16 +02:00
Niels f3447b2b80 Appveyor 2015-04-26 23:14:51 +02:00
Niels 4a3c0edb75 Appveyor 2015-04-26 23:09:10 +02:00
Niels 4c7fbd7647 Appveyor 2015-04-26 23:03:15 +02:00
Niels 711e465f4a Appveyor test 2015-04-26 22:53:17 +02:00
Niels 1e20bfa14a another try 2015-04-26 22:47:40 +02:00
Niels ae2676e7f0 fixed Makefile 2015-04-26 22:25:38 +02:00
Niels 5e0d4d3830 does not 2015-04-26 22:09:15 +02:00
Niels a3ca1ae217 trying appveyor again 2015-04-26 22:00:20 +02:00
Niels 81d3973151 undid changes that broke the build 2015-04-26 21:51:35 +02:00
Niels f874b5f0f8 clean up
- removed m_final member
- parse_internal now takes a reference to a basic_json object to fill
with data
- header is automatically regenerated if re2c file is changed
2015-04-26 21:43:47 +02:00
Niels f09df96742 updated README 2015-04-26 15:16:07 +02:00
Niels 7a32bd22e9 Merge pull request #63 from Florianjw/master
Improve the implementations of the comparission-operators
2015-04-26 15:10:32 +02:00
Niels c7f95cc636 minor change to the parsing of objects/arrays 2015-04-26 15:10:04 +02:00
Florian Weber 4fbff7d140 simplify value_t::operator< by using a lookup-table 2015-04-26 14:55:06 +02:00
Florian Weber f5e95522aa remove braces around single-return-statement switch-cases 2015-04-26 14:44:56 +02:00
Florian Weber d2771eb1bb Fix comparission between integers and floats
Until now it depended on the parameter-order whether
integers and floats were compared as integers or floats.

Appart from being not logical, this might even have meant that
the provided “order” was in fact not that. (not sure here, but I
like to be carefull)
2015-04-26 14:39:39 +02:00
Florian Weber 306695dd25 fix typos and improve operator== 2015-04-26 14:31:31 +02:00
Florian Weber 28f64c22a9 simplify operator< 2015-04-26 14:19:56 +02:00
Niels a372937424 fixed some small issues 2015-04-26 13:37:01 +02:00
Niels e3ab0bc74a addressing issue #62 2015-04-25 23:10:23 +02:00
Niels 89a8491914 minor changes 2015-04-25 01:25:42 +02:00
Niels fc58a73523 fix #60 (double escaping) 2015-04-24 22:06:57 +02:00
Niels 28f21c43f4 updated README to recent pull request 2015-04-15 17:52:25 +02:00
Niels 3eb1b2a756 Merge pull request #59 from dkopecek/master
Fix compilation of json_unit with GCC 5
2015-04-15 08:53:40 +02:00
Daniel Kopecek ad6ad4ae1e Fix compilation of json_unit with GCC 5
Addressing:
```
+ make json_unit
g++ -std=c++11  -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal  -I src -I test -Dprivate=public test/unit.cpp  -o json_unit
In file included from test/catch.hpp:65:0,
                 from test/unit.cpp:11:
/usr/include/c++/5.0.0/sstream:300:7: error: 'struct std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>::__xfer_bufptrs' redeclared with different access
       struct __xfer_bufptrs
```
2015-04-14 16:02:49 +02:00
Niels 4c55ada0f7 another test case 2015-04-12 18:33:38 +02:00
Niels 6ddb115072 more coverage 2015-04-12 18:12:29 +02:00
Niels 2dd94dd943 some simplifications 2015-04-12 17:26:54 +02:00
Niels f03c6ce458 added missing test cases 2015-04-12 16:57:51 +02:00
Niels dda8a5c473 adjusted code to documentation; some cleanup 2015-04-12 16:19:21 +02:00
Niels 139ef0e750 implemented front() and back() 2015-04-12 14:14:00 +02:00
Niels ade49f8b2a constructor for an integer range 2015-04-12 13:15:26 +02:00
Niels b801adca76 started to implement sequence container 2015-04-12 12:02:30 +02:00
Niels 02f617f083 adjusted code to documentation 2015-04-11 19:26:12 +02:00
Niels a3210ee2a9 increase test coverage 2015-04-11 15:42:54 +02:00
Niels 6dceab583c implemented issue #57: erase with iterators 2015-04-11 15:30:19 +02:00
Niels d7d0509161 added a note about supported compilers to close #50 2015-04-09 19:21:24 +02:00
Niels 84195daf28 added erase function for arrays 2015-04-09 18:55:57 +02:00
Niels 9ea3dd9b60 another test case 2015-04-08 23:16:35 +02:00
Niels 9e8e11339d improved test case coverage 2015-04-08 22:58:35 +02:00
Niels 1bdb6acb1f overworked type conversion 2015-04-08 22:23:40 +02:00
Niels 0a96116b0c more SFINAE 2015-04-03 16:34:39 +02:00
Niels ea1046110d using "key_type" where possible 2015-04-03 14:43:44 +02:00
Niels b747881466 subtle fix for get() function 2015-04-03 14:20:15 +02:00
Niels 7db167afd1 documented empty() 2015-04-01 23:23:36 +02:00
Niels 9767523924 don't need this 2015-03-31 23:10:34 +02:00
Niels babaa11c99 Bower spec 2015-03-31 22:56:33 +02:00
Niels 3eb50dde30 added RTD badge 2015-03-31 22:41:51 +02:00
Niels e0027a8550 cleanup docs 2015-03-31 22:40:21 +02:00
Niels f9c4b02092 rename to check something with RTD 2015-03-31 22:39:16 +02:00
Niels 71fa44a6af started documentation with RTD 2015-03-31 22:24:28 +02:00
Niels c9379b68dd fix #52 (documented new functions) 2015-03-27 17:11:08 +01:00
Niels 5e89cb0acb implemented key()/value() for reverse iterators 2015-03-26 17:06:33 +01:00
Niels 47ea1c10d4 key/value function for iterators (#46)
Currently only support iterator and const_iterator. reverse_iterator
and const_reverse_iterator to be implemented soon.
2015-03-24 19:08:03 +01:00
Niels 8fc4061187 fixed acknowledgements 2015-03-24 19:06:40 +01:00
Niels 0707030bc5 minor changes to pull request #40 2015-03-24 18:05:58 +01:00
Niels 50e06a7bd1 Merge pull request #40 from aburgh/incremental
Parse streams incrementally.
2015-03-24 17:57:40 +01:00
Niels e3188897f8 more on #48: allowing non-std begin/end functions 2015-03-24 17:39:00 +01:00
Niels 6fc52f3302 fixed #47 (added erase function to remove key form object) 2015-03-24 16:50:55 +01:00
Niels 43417c350b fixed #42 (removed equality comparisons for floats) 2015-03-23 23:03:48 +01:00
Niels 8e1c5f2221 updated README 2015-03-23 20:30:51 +01:00
Niels 53e3da8071 minor adjustments to pull request #38 2015-03-23 20:27:30 +01:00
Niels a382a93a8e Merge pull request #38 from wtsi-hgi/feature/small-float-serialization
Feature/small float serialization
2015-03-23 20:15:50 +01:00
Niels bb2671df11 fixed #43 (adding friendship to allow iterator change) 2015-03-22 19:18:21 +01:00
Niels f2957dc3bf fixed #45 (added count function for keys in objects) 2015-03-22 19:07:43 +01:00
Niels cf829ac2e8 fixed deprecated warnings in issue #42 2015-03-22 17:50:43 +01:00
Niels abc6137001 fixed #48 (using nonmember begin/end) 2015-03-22 17:30:48 +01:00
Aaron Burghardt 396f64a058 Replaced leading tabs with spaces (4 per tab). 2015-03-02 15:25:09 -05:00
Aaron Burghardt 87746280ca Added parse() for streams. 2015-03-01 06:31:33 -05:00
Aaron Burghardt 2855c70c27 Use inplace configuration for yyfill and disable the parameter to yyfill. 2015-03-01 05:55:40 -05:00
Aaron Burghardt 268fd444e6 Added comments to new method yyfill. 2015-03-01 05:55:40 -05:00
Aaron Burghardt edb697293b Fixed variable adjustments in yyfill(). 2015-03-01 05:55:40 -05:00
Aaron Burghardt ec6979bf76 Purged old commented-out code. 2015-03-01 05:55:40 -05:00
Aaron Burghardt b66c306d47 Removed unused member m_state. 2015-03-01 05:55:40 -05:00
Aaron Burghardt 0d79e7c2a2 Removed duplicate m_marker updates in YYFILL macro. 2015-03-01 05:55:40 -05:00
Aaron Burghardt e3e18d7b85 Deleted extraneous comment. 2015-03-01 05:55:40 -05:00
Aaron Burghardt e4cc42cf81 Moved m_marker in lexer::scan() to be a member of lexer. 2015-03-01 05:55:40 -05:00
Aaron Burghardt 754c38e871 Moved buffer management into the lexer class and implemented YYFILL so that streams are read incrementally. 2015-03-01 05:55:40 -05:00
Joshua C. Randall 7bfcbe2825 Fixes serialization of small floats
Now uses std::snprintf() to generate a "%.15g" formatted string
for JSON values of type number_float. 15 decimals digits are
enough to round-trip an IEEE 754 double from string->double->string
and get an identical result.

std::snprintf is called twice. Once to determine the required
buffer size and then again after allocating a buffer of that
size.

Note that the buffer size *could* be hardcoded for better
performance. "%.15g" should result in strings of maximum length
23, plus one character for the terminating null for a buffer size
of 24.
2015-02-28 17:11:46 +00:00
Joshua C. Randall ef3ad895ae Adds (failing) test for small float serialisation 2015-02-28 15:53:48 +00:00
Niels 5526de1385 small syntax fix 2015-02-25 22:21:05 +01:00
Niels 63c70fa07e minor changes 2015-02-24 23:19:19 +01:00
Niels ec42245951 small change to GIF 2015-02-22 22:24:47 +01:00
Niels c9b5357227 increased delays in GIF 2015-02-22 18:09:22 +01:00
Niels 93b585afa4 added GIF 2015-02-22 17:55:25 +01:00
Niels d524e23204 overworked iterators 2015-02-22 17:52:27 +01:00
Niels bc2e3a798d a more forgiving array behavior 2015-02-21 13:24:07 +01:00
Niels 1cd256a95e minor syntax error in README 2015-02-19 00:06:15 +01:00
Niels 118ec996fd Merge pull request #36 from nlohmann/template
template version with re2c scanner
2015-02-19 00:04:28 +01:00
Niels c8c49dae5d fixed coverage 2015-02-18 22:43:25 +01:00
Niels afd02eee44 fixed [] operator; added README 2015-02-18 22:28:56 +01:00
Niels ca981270a0 added another test case 2015-02-17 00:36:29 +01:00
Niels 9e7941b6ba more type adjustments 2015-02-17 00:22:12 +01:00
Niels e2dff46d14 further type adjustments 2015-02-16 23:34:37 +01:00
Niels 432a54e570 some type fixes 2015-02-16 23:17:28 +01:00
Niels a3f52a5a04 minor change to make code more portable 2015-02-16 22:54:07 +01:00
Niels 5ca84052a7 removed unused code and fixed includes 2015-02-16 22:47:30 +01:00
Niels db91140156 clean up 2015-02-15 23:27:35 +01:00
Niels 429d2099ab more allocators 2015-02-15 23:13:46 +01:00
Niels b387761e12 forgot to destroy object 2015-02-15 22:58:35 +01:00
Niels 568d75954e experiment with user-defined allocator 2015-02-15 22:49:26 +01:00
Niels b1be1b45ee minor change 2015-02-15 18:43:17 +01:00
Niels d31d1ca664 fix of the fix 2015-02-15 17:40:46 +01:00
Niels 9f87fd464a fixed Valgrind error 2015-02-15 17:07:19 +01:00
Niels f1f72403cd some unicode magic 2015-02-15 16:56:54 +01:00
Niels 3e885c8328 added missing test case 2015-02-15 15:51:11 +01:00
Niels af568b9b27 test cases for new features 2015-02-15 15:45:00 +01:00
Niels b80ca376f9 added some missing features from 2.0 version 2015-02-15 15:16:11 +01:00
Niels 2d8b362849 further cleanup 2015-02-15 14:52:00 +01:00
Niels 2fc82358ce clean up 2015-02-15 13:35:51 +01:00
Niels b21bf95620 fixed test case coverage 2015-02-15 11:53:24 +01:00
Niels bb558d8e6f added Unicode support 2015-02-15 11:44:49 +01:00
Niels 6ef3cb51a4 some reorganization 2015-02-14 17:34:06 +01:00
Niels cc4a8319a1 reverse iterators 2015-02-14 16:47:14 +01:00
Niels d87e770767 forgot Makefile 2015-02-13 22:12:27 +01:00
Niels 005a5c2858 some fixes and cleanup 2015-02-13 21:46:33 +01:00
Niels 36e36bf84a two more test cases for numbers 2015-02-13 20:27:27 +01:00
Niels 3391e69248 six more test cases for numbers 2015-02-13 20:16:53 +01:00
Niels e346011876 more test cases for numbers 2015-02-13 20:02:36 +01:00
Niels c864ea2199 systematic test case for \uxxxx sequences 2015-02-13 18:57:28 +01:00
Niels 334b7f24ea more systematic test cases 2015-02-13 18:18:58 +01:00
Niels 40a0773e43 more test cases 2015-02-13 17:42:14 +01:00
Niels 4361c4d03f more test cases 2015-02-12 22:54:42 +01:00
Niels 583d20a3b1 more test cases 2015-02-11 22:42:49 +01:00
Niels 89a1b0247b fixed a major bug in the parser 2015-02-11 17:24:14 +01:00
Niels 3f8dc632e2 test cases for iterator classes 2015-02-11 15:29:41 +01:00
Niels 53c9564c51 bug fix and test cases 2015-02-11 14:58:52 +01:00
Niels 4d23c49601 another test case 2015-02-11 13:25:04 +01:00
Niels 7b7a54aca5 fixed a bug 2015-02-11 13:15:22 +01:00
Niels 032bcf6493 more test cases (unexpected ends) 2015-02-11 12:53:47 +01:00
Niels 1d177f82bd more test cases (0e1) 2015-02-11 12:36:30 +01:00
Niels cb96e30f25 try to understand re2c 2015-02-11 12:21:46 +01:00
Niels c1bf002522 more test cases (objects, floats) 2015-02-11 11:57:36 +01:00
Niels 3f46fe7a08 more test cases 2015-02-11 11:47:00 +01:00
Niels f1bd206994 number test cases 2015-02-11 11:36:45 +01:00
Niels 463c38df60 fix test case 2015-02-11 10:57:17 +01:00
Niels 4b9bd96ab1 re-added old (failing) test cases 2015-02-11 10:27:41 +01:00
Niels c816fd12a0 cleanup 2015-02-11 10:16:43 +01:00
Niels d609790fff added whitespace handling 2015-02-11 09:51:24 +01:00
Niels 5d280143b7 fixes 2015-02-11 09:41:23 +01:00
Niels 8a4e127a57 + moved lexer to class 2015-02-11 09:10:28 +01:00
Niels e845cd1db8 still errors... 2015-02-10 23:55:44 +01:00
Niels a201bc981d more test cases 2015-02-10 23:45:18 +01:00
Niels f6f7fcc88c another test case 2015-02-10 23:28:25 +01:00
Niels 0433e71fc3 rename member variables; add whitespace tests 2015-02-10 23:20:30 +01:00
Niels f9797f8eb2 try 2015-02-10 23:05:45 +01:00
Niels 1aebb6e6ed removing failing (?) test cases 2015-02-10 22:48:16 +01:00
Niels 6232c78f88 possible fix 2015-02-10 22:37:07 +01:00
Niels 1bbde4597b more test cases 2015-02-10 22:09:21 +01:00
Niels cd89a88b4a fix build error 2015-02-10 21:03:32 +01:00
Niels 963ec13b4a testing the parser 2015-02-10 20:52:39 +01:00
Niels 3589837071 more test cases 2015-02-10 20:28:16 +01:00
Niels 8c6bb04d10 added width feature / more test cases 2015-02-10 19:50:26 +01:00
Niels 4cd341d4db more unit tests 2015-02-10 18:51:09 +01:00
Niels 29a8d43d5a fixed tests for copy assignment 2015-02-10 17:40:47 +01:00
Niels d760ff5142 tests for comparison operators 2015-02-10 17:10:39 +01:00
Niels 2ec0c79e0f test cases and clean up 2015-02-09 21:10:19 +01:00
Niels 0cfd0f5d68 added test cases and fixed some warnings 2015-02-09 20:21:26 +01:00
Niels 0df642ded0 more test cases 2015-02-09 19:49:09 +01:00
Niels e53e84e1cc more test cases 2015-02-09 18:45:32 +01:00
Niels 48392cfa79 some bug fixing 2015-02-09 18:02:31 +01:00
Niels fe64ed5f01 another fix for travis 2015-02-08 19:22:48 +01:00
Niels 330ffd952b removed reverse_iterators and fixed some bugs 2015-02-08 19:18:39 +01:00
Niels 4c59ccd1d5 a fix for Travis 2015-02-08 18:38:24 +01:00
Niels 5b4dcfd8a4 more test cases 2015-02-08 18:27:16 +01:00
Niels 4a0ce18034 more test cases 2015-02-08 18:06:16 +01:00
Niels 27eab94ea1 more test cases 2015-02-08 17:45:56 +01:00
Niels a35d93e980 try with GCC 4.9 2015-02-08 16:57:53 +01:00
Niels d6f54711f3 hello coveralls... 2015-02-08 16:44:27 +01:00
Niels 572232614d more test cases 2015-02-08 16:37:21 +01:00
Niels 323764a8c5 more test cases 2015-02-08 16:24:38 +01:00
Niels d38596793e more test cases 2015-02-08 16:14:49 +01:00
Niels 441a6f267f more test cases 2015-02-08 16:08:48 +01:00
Niels 8ed9eaa629 more test cases 2015-02-08 15:57:24 +01:00
Niels 16b91d491e more test cases 2015-02-08 15:47:40 +01:00
Niels d0df796a10 more test cases 2015-02-08 14:54:16 +01:00
Niels 7cd9067ea2 more test cases 2015-02-08 14:38:52 +01:00
Niels 43ec6477bd more test cases 2015-02-08 14:10:36 +01:00
Niels f442b0d72c more test cases 2015-02-08 13:52:11 +01:00
Niels 5877bb9745 systematic unit tests 2015-02-08 13:25:09 +01:00
Niels caf82be2c7 added reverse iterators 2015-02-08 12:53:10 +01:00
Niels 87c250d843 another commit to trigger coverage 2015-02-07 19:14:23 +01:00
Niels cc274f8145 small changes with default values 2015-02-07 19:04:08 +01:00
Niels c1c3e72c96 include main source file for coveralls 2015-02-07 16:03:40 +01:00
Niels cf498ca4f2 added more features from master branch 2015-02-07 15:57:47 +01:00
Niels ac274dee2a Zwischenstand 2015-02-05 22:45:33 +01:00
Niels 16fa85e9f2 Zwischenstand 2015-02-05 22:45:21 +01:00
Niels a5188b08df strings are escaped 2015-02-04 22:49:46 +01:00
Niels 5ec433604a more test cases 2015-01-31 21:25:38 +01:00
Niels 385865c4ec remove checks in iterator 2015-01-31 20:46:23 +01:00
Niels 9dff05d9e3 exclude more files from coveralls 2015-01-31 20:31:43 +01:00
Niels d8f58b25fb coveralls adjustment 2015-01-31 20:26:47 +01:00
Niels 087010032d adjustments to coverall 2015-01-31 20:19:36 +01:00
Niels befd90dead cleanup 2015-01-31 20:13:11 +01:00
Niels c4d74856bb Merge pull request #33 from luxe/patch-1
more descriptive documentation in example
2015-01-26 07:51:40 +01:00
Trevor Hickey 20d75a26a5 more descriptive documentation in example
I wasn't sure what that parameter was at first glance
2015-01-25 21:00:28 -05:00
Niels b453cdb7a2 more examples 2015-01-24 21:11:42 +01:00
Niels 85aa0a328e updated README 2015-01-24 21:06:05 +01:00
Niels 5199382c91 worked on issue #8 and #27 2015-01-24 20:33:06 +01:00
Niels 47e3a3ed24 another test case 2015-01-23 20:46:46 +01:00
Niels f8d263a811 another test case 2015-01-23 18:42:24 +01:00
Niels 807de40463 implemented missing operator[] 2015-01-23 18:27:58 +01:00
Niels 36f14d21da more test cases for reverse iterators 2015-01-23 18:07:31 +01:00
Niels c22ee3f296 fixed an issue with non portability 2015-01-21 18:04:12 +01:00
Niels 6ee46ed519 cleanup 2015-01-21 17:42:45 +01:00
Niels d66743b9c2 fixed a memory leak 2015-01-21 15:59:52 +01:00
Niels bbc45eb4d8 overworked iterators 2015-01-21 15:43:24 +01:00
Niels 76be1ae1f6 + more adjustments toward a real container 2015-01-21 11:47:03 +01:00
Niels 3c780f0f57 + generic constructors for arrays and objects 2015-01-21 09:40:46 +01:00
Niels 7afabc2b7e another test case 2015-01-20 22:06:45 +01:00
Niels ee45bca4a9 + more test cases 2015-01-20 21:49:21 +01:00
Niels 75ba6ae4ff + improved test case coverage 2015-01-20 21:35:08 +01:00
Niels a7a946bd18 added missing header 2015-01-20 21:15:14 +01:00
Niels 54fc97d434 + set number type to int64_t
+ replaced several functions by template magic
2015-01-20 20:43:54 +01:00
Niels a144800774 + implemented member and non-member swap 2015-01-19 19:51:07 +01:00
Niels 7724d34741 fixed #31: only use spaces in pretty print 2015-01-18 10:58:48 +01:00
Niels b30e9ee5f4 test cases to cover 100% of the fix of #28 2015-01-13 19:26:42 +01:00
Niels 19043d2003 this should fix #28 2015-01-13 19:07:53 +01:00
Niels d47b0e749b updated README 2015-01-12 23:38:55 +01:00
Niels dcf71748a6 Merge pull request #26 from wancw/fix_clang_string_casting
Fix string conversion under Clang
2015-01-12 22:54:39 +01:00
WanCW 36f6199898 Fix string conversion under Clang 2015-01-12 20:03:41 +08:00
Niels bd05c7a18a small tidy up after pull request #22
- removed IDE leftovers
- adjusted const’ness of some functions
- style guide
2015-01-11 15:16:14 +01:00
Niels 6533b33387 Merge pull request #22 from Teemperor/unicode_escaping
Unicode escaping
2015-01-11 15:08:13 +01:00
Niels 8d9c2bea4e + applied style guide 2015-01-11 15:05:04 +01:00
Niels 80b5db16b5 Merge pull request #24 from Teemperor/fix_string_dumping
Fixed dumping of strings
2015-01-11 14:03:53 +01:00
Niels cc7e942870 Merge pull request #23 from Teemperor/gcc_remark_readme
Added a remark to the readme that coverage is GCC only for now
2015-01-11 12:47:00 +01:00
Raphael Isemann 7b97ec884e Fixed dumping of strings 2015-01-10 22:04:57 +01:00
Raphael Isemann a866a9d980 Reapplied code style fixes 2015-01-10 19:53:13 +01:00
Raphael Isemann a409ba9488 Fixed build 2015-01-10 18:46:01 +01:00
Raphael Isemann 0fcc414995 More testing and updated CMake to allow calling private functions from the tests 2015-01-10 18:28:53 +01:00
Raphael Isemann 85888e8205 Added a remark to the readme that coverage is GCC only for now 2015-01-10 18:09:46 +01:00
Raphael Isemann 6105ce5484 Allowed automerge 2015-01-10 17:33:18 +01:00
Raphael Isemann 1287f03084 Code point are two words, and so the "P" should be capital 2015-01-10 16:50:39 +01:00
Raphael Isemann 5a54e46709 Fully implemented the JSON spec 2015-01-10 16:49:10 +01:00
Raphael Isemann 222aacc213 Quick and dirty implementation for basic multilingual plane in the unicode escape mechanism 2015-01-10 10:36:30 +01:00
Niels 0cd2ecf48f minor style adjustments 2015-01-09 20:48:16 +01:00
Niels 3fa2e900ef + added Thanks section to README 2015-01-09 20:48:06 +01:00
Niels 69195e070f Merge pull request #21 from Teemperor/fixed_escaped_chars
Implemented the JSON spec for string parsing for everything but the \uXXXX escaping - see issue #12.
2015-01-09 20:32:08 +01:00
Raphael Isemann 13efc7a02a More tests to get line coverage backt o 100% 2015-01-09 20:24:58 +01:00
Raphael Isemann 7f4fcc51f6 Implemented the JSON spec for string parsing for everything but the \uXXXX escaping for unicode 2015-01-09 20:03:18 +01:00
Niels 52f399d55f created a header-only version (see issue #16) 2015-01-09 18:16:27 +01:00
Niels 2443aa6521 updated README 2015-01-09 17:50:50 +01:00
Niels 33f5236687 added missing header 2015-01-09 17:40:14 +01:00
Niels 535aef5ad0 Merge pull request #19 from kirkshoop/stditerator
add the std iterator typedefs to iterator and const_iterator
2015-01-09 17:37:42 +01:00
Niels 33f5e74905 minor syntax adjustments 2015-01-09 16:38:34 +01:00
Kirk Shoop 3486a5d9bb add the std iterator typedefs to iterator and const_iterator 2015-01-09 07:33:57 -08:00
Niels 661a44d156 Merge pull request #18 from Teemperor/fix_quote_escaping
Fixed escaped quotes (issue #17)
2015-01-09 16:32:39 +01:00
Raphael Isemann 4a39bfb17e Fixed typo in comments 2015-01-09 11:57:39 +01:00
Raphael Isemann fa0ee9c927 Fixed escaped quotes 2015-01-08 22:35:48 +01:00
Niels 4647401030 fixed #15 2015-01-06 22:05:32 +01:00
Niels bd9f49efb9 implemented pretty printing (issue #13)
- to_string() method is now called dump()
- syntax borrowed from Python’s json.dumps()
2015-01-06 21:44:07 +01:00
Niels 08456b8ff0 minor changes 2015-01-06 19:14:03 +01:00
Niels d84f8ebb02 valgrind parameter is not understood in travis 2015-01-06 18:57:44 +01:00
Niels 43a85be471 travis now checks with valgrind 2015-01-06 18:52:14 +01:00
Niels 5f05d02c6a Merge pull request #14 from elliotgoodrich/master
Fix double delete on std::bad_alloc exception
2015-01-06 18:43:21 +01:00
Niels a53c878c81 moved class into "nlohmann" namespace
- fixed issue #9
- also removed std::mutex member variable
- also added “std::” prefix to size_t variables
2015-01-06 18:41:24 +01:00
Elliot Goodrich 0773f40a8e Fix double delete on std::bad_alloc exception
If the new operator throws in the json::find methods then result.oi_ is
deleted again in the destructor of json::iterator/json::const_iterator,
which is a double delete and undefined behaviour.
2015-01-06 09:12:55 +00:00
Niels 4f0afbbe64 added note from http://isocpp.org/blog/2015/01/json-for-modern-cpp 2015-01-05 22:25:44 +01:00
Niels f0582a8b60 ignore some CMake files 2015-01-05 20:36:31 +01:00
Niels bf768d96d9 minor Markdown error 2015-01-05 20:30:34 +01:00
Niels b39f78924a Merge pull request #6 from Teemperor/master
Added CMake and lcov
2015-01-05 20:28:56 +01:00
Raphael Isemann 67459fcd83 Added CMake to the README 2015-01-05 11:29:41 +01:00
Raphael Isemann bd4e0e4fee Merge branch 'master' of github.com:nlohmann/json 2015-01-05 11:20:32 +01:00
Raphael Isemann 0f371b4086 CMake and coverage report 2015-01-05 11:19:42 +01:00
Niels a9669a410d removed "noexpect" from all functions that use new 2015-01-04 23:18:24 +01:00
Niels 540cda6118 used _-suffix for member variables 2015-01-04 23:09:30 +01:00
Niels 3bef1a5097 renamed "toString()" to "to_string()" 2015-01-04 20:50:28 +01:00
Niels f63ff7727e renamed class from "JSON" to "son" 2015-01-04 20:43:25 +01:00
Niels 4d00105e5c tidy up 2015-01-04 19:05:46 +01:00
Niels 0019c85b85 fix 2015-01-04 18:55:15 +01:00
Niels aa166a4739 updated examples 2015-01-04 18:52:04 +01:00
Niels 77ea63ceb5 fixed a link 2015-01-04 18:32:03 +01:00
Niels 4ea98517f5 updated README 2015-01-04 13:20:32 +01:00
Niels bd0be5f0af fixed memory leak 2015-01-04 12:29:16 +01:00
Niels 481f377cfe + guard call to std::ios_base::sync_with_stdio 2015-01-04 12:05:28 +01:00
Niels 9537c70b67 removing flawed test case 2015-01-03 17:51:14 +01:00
Niels 764ed26c41 cleanup 2015-01-03 17:18:17 +01:00
Niels 18364aac85 parser returns an object 2015-01-02 17:19:40 +01:00
Niels 16c30cff8b removed old C fragments 2015-01-02 15:29:36 +01:00
Niels af4aca9edd + better string handling 2015-01-02 12:47:32 +01:00
Niels 85abe926cf fixed coveralls call to ignore benchmarks folder 2014-12-30 12:02:38 +01:00
Niels 6995d33fb1 + fixed documentation bugs 2014-12-30 11:57:58 +01:00
Niels 2335d3f3d5 tidy up 2014-12-30 11:47:28 +01:00
Niels 39cf26e2db minor changes 2014-12-30 11:29:59 +01:00
Niels 2be4f24837 + updated reference 2014-12-30 11:19:35 +01:00
Niels 9e61092fc6 + overworked parser 2014-12-30 10:54:01 +01:00
Niels 4e44390090 + fixed a bug in the stream input 2014-12-29 21:13:03 +01:00
Niels 15a9d3cff6 minor changes 2014-12-29 19:54:31 +01:00
Niels 0b8dda1e0c minor changes 2014-12-29 18:32:17 +01:00
Niels f50fdd08a7 syntax highlighting 2014-12-29 18:20:55 +01:00
Niels 6687ea1a36 updated reference 2014-12-29 18:19:06 +01:00
Niels cff4d40afd type reference 2014-12-29 17:07:00 +01:00
Niels a8c4f84fb8 + removed data() function 2014-12-29 16:45:54 +01:00
Niels 515d731fd4 + documentation 2014-12-29 13:35:52 +01:00
Niels 725202356b + fix memory issues 2014-12-29 12:51:20 +01:00
Niels 2c1b3e5108 + small cleanup 2014-12-29 00:02:14 +01:00
Niels 3985226f76 issue badge 2014-12-28 23:21:46 +01:00
Niels bed47db168 + that could be it! 2014-12-28 23:09:31 +01:00
Niels 776611c270 + another check 2014-12-28 22:59:11 +01:00
Niels 0ced78bfa8 + test 2014-12-28 22:51:27 +01:00
Niels b573841ace + more test cases 2014-12-28 22:38:57 +01:00
Niels 98af0887f2 + more test cases 2014-12-28 22:29:06 +01:00
Niels ea85da8a55 + more test cases 2014-12-28 22:16:58 +01:00
Niels aacb58e56b + more test cases 2014-12-28 22:07:10 +01:00
Niels 48a349a058 + more test cases 2014-12-28 21:53:13 +01:00
Niels 8f45d9351e + overworked switches 2014-12-28 20:07:56 +01:00
Niels 4810091bab + more test cases 2014-12-28 19:51:02 +01:00
Niels b2b5e4e7e1 + more test cases 2014-12-28 18:12:07 +01:00
Niels cd48a01b20 + more test 2014-12-28 18:00:50 +01:00
Niels d3216300b2 + more test cases 2014-12-28 17:26:33 +01:00
Niels ea94518a64 + more test cases 2014-12-28 17:09:38 +01:00
Niels 5b1f69ce5b + overworked comments 2014-12-28 16:48:22 +01:00
Niels 45b101d200 + more test cases 2014-12-28 15:57:43 +01:00
Niels 6561e4e424 + execute unit tests explicitly 2014-12-28 15:46:36 +01:00
Niels 75b2f4098d + more test cases 2014-12-28 15:41:33 +01:00
Niels a68b4cafa2 + more test cases 2014-12-28 14:57:21 +01:00
Niels 2e26faf91c + more test cases 2014-12-28 14:39:34 +01:00
Niels 88786c86bb more test cases 2014-12-28 13:40:19 +01:00
Niels ef5b589686 more test cases 2014-12-28 13:31:24 +01:00
Niels 215391983a + more test cases 2014-12-28 13:22:06 +01:00
Niels 1c10efb7be + error fix 2014-12-28 13:11:50 +01:00
Niels 0720323ed7 another test case 2014-12-28 13:09:38 +01:00
Niels 8d4f675151 + test cases for clear() 2014-12-28 12:50:52 +01:00
Niels b60fe6e7e2 - removed old test cases 2014-12-28 12:38:08 +01:00
Niels 23006bd57b exclude tests 2014-12-28 12:24:52 +01:00
Niels 87d24ca670 pass gcov version 2014-12-28 12:20:53 +01:00
Niels 08a60a7803 clang seems not to work 2014-12-28 11:27:38 +01:00
Niels 1cb6426ddc wrong package name 2014-12-28 11:24:40 +01:00
Niels 41ab5b1f59 + fixing coverall 2014-12-28 11:20:48 +01:00
Niels 822172c502 make pretty 2014-12-28 11:15:13 +01:00
Niels 9f562caa2c Merge pull request #5 from nlohmann/2.0
Version 2.0
2014-12-28 11:09:35 +01:00
Niels 30ac86a0fe + updated README 2014-12-28 11:06:01 +01:00
Niels db804169c7 added coverage badge 2014-12-28 09:29:33 +01:00
Niels b57179e0fe + fixed a compiler warning
+ added coveralls
2014-12-28 09:23:49 +01:00
Niels 36fcc942c4 using GCC 4.8 for Travis 2014-12-28 09:21:06 +01:00
Niels fbad7fac17 2.0 preview 2014-12-28 09:11:01 +01:00
Niels d1ac3d9938 benchmark 2013-12-11 13:23:50 +01:00
Niels 5dbdba3c43 towards a benchmark 2013-12-11 10:50:50 +01:00
Niels bbc0f64fa5 a Makefile target for test coverage 2013-12-11 10:23:31 +01:00
Niels d47a81296f fixed a typo 2013-12-11 08:49:07 +01:00
Niels 77fa133946 removed unused flags 2013-12-11 08:41:12 +01:00
Niels 278a9e7052 simplified code 2013-12-11 08:41:02 +01:00
Niels 442cc9b6de added debug output to test cases 2013-12-11 08:40:53 +01:00
Niels 81367a9a10 fixed a cppcheck warning 2013-12-10 12:44:23 +01:00
Niels Lohmann a8f62ca052 + a fix for C++98 2013-07-15 08:32:10 +02:00
Niels 9a567d9d2d - tidied code
- added more documentation
2013-07-11 14:19:11 +02:00
Niels 52c2cb8ce7 - removed pointers to POD inside the union 2013-07-10 14:57:51 +02:00
Niels 4e6a400a23 - reorganized payload 2013-07-10 14:33:17 +02:00
Niels ec6e628d4f - minor tweaks 2013-07-05 16:45:17 +02:00
Niels cb2da141ec - further adjustments 2013-07-05 16:15:29 +02:00
Niels 6abf140b2b - updated README 2013-07-05 14:57:03 +02:00
Niels d5c56f2771 - a README 2013-07-05 14:44:45 +02:00
Niels 0ee8d53a28 - a find() function 2013-07-05 14:16:47 +02:00
Niels ac5ff65856 - bugfixing 2013-07-05 12:32:23 +02:00
Niels abad903f31 - memory problem 2013-07-05 11:57:12 +02:00
Niels 61461ec456 - fixes from Harro 2013-07-05 11:23:49 +02:00
Niels 23ada516aa - header for NULL 2013-07-04 18:16:24 +02:00
Niels d035fa581d - added missing headers 2013-07-04 18:13:17 +02:00
Niels ff41ca8fd6 - removing Autoconf version requirement to allow travis to work 2013-07-04 17:13:04 +02:00
Niels 206e15dff7 - fixed bugs and added test cases 2013-07-04 17:06:53 +02:00
Niels ac6ced6fb8 - a config file for travis 2013-07-04 10:54:16 +02:00
Niels b9465f8d65 - ignore DS_Stores 2013-07-04 10:49:35 +02:00
Niels 4502e7e51c - initial commit 2013-07-04 10:49:03 +02:00
2949 changed files with 5403391 additions and 91249 deletions
-3
View File
@@ -1,3 +0,0 @@
# JSON for Modern C++
![](images/json.gif)
+71
View File
@@ -0,0 +1,71 @@
[![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/pr?style=flat)](http://issuestats.com/github/nlohmann/json) [![Issue Stats](http://issuestats.com/github/nlohmann/json/badge/issue?style=flat)](http://issuestats.com/github/nlohmann/json)
# How to contribute
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!
## Private reports
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>.
## 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.
## Describe your issue
Clearly describe the issue:
- If it is a bug, please describe how to **reproduce** it. If possible, attach a complete example which demonstrates the error. Please also state what you **expected** to happen instead of the error.
- 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.
## Files to change
:exclamation: Before you make any changes, note the single-header file [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) is **generated** from the source files in the [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). Please **do not** edit file `single_include/nlohmann/json.hpp` directly, but change the `include/nlohmann` sources and regenerate file `single_include/nlohmann/json.hpp` by executing `make amalgamate`.
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.
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
```sh
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
$ ctest
```
The test cases are also executed with several different compilers on [Travis](https://travis-ci.org/nlohmann/json) once you open a pull request.
## Note
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
## Please don't
- 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.8 (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.
- 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).
- Please do not open pull requests that address **multiple issues**.
## Wanted
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.
- 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.
+19
View File
@@ -0,0 +1,19 @@
---
name: Bug report
about: Create a report to help us improve
---
- What is the issue you have?
- Please describe the steps to reproduce the issue. Can you provide a small but working code example?
- What is the expected behavior?
- And what is the actual behavior instead?
- Which compiler and operating system are you using? Is it a [supported compiler](https://github.com/nlohmann/json#supported-compilers)?
- Did you use a released version of the library or the version from 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)?
@@ -0,0 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
---
- Describe the feature in as much detail as possible.
- Include sample usage where appropriate.
+19
View File
@@ -0,0 +1,19 @@
[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
* * *
## Pull request checklist
Read the [Contribution Guidelines](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md) for detailed information.
- [ ] Changes are described in the pull request, or an [existing issue is referenced](https://github.com/nlohmann/json/issues).
- [ ] The test suite [compiles and runs](https://github.com/nlohmann/json/blob/develop/README.md#execute-unit-tests) without error.
- [ ] [Code coverage](https://coveralls.io/github/nlohmann/json) is 100%. Test cases can be added by editing the [test suite](https://github.com/nlohmann/json/tree/develop/test/src).
- [ ] The source code is amalgamated; that is, after making changes to the sources in the `include/nlohmann` directory, run `make amalgamate` to create the single-header file `single_include/nlohmann/json.hpp`. The whole process is described [here](https://github.com/nlohmann/json/blob/develop/.github/CONTRIBUTING.md#files-to-change).
## Please don't
- 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.8 (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 do not open pull requests that address **multiple issues**.
+19
View File
@@ -0,0 +1,19 @@
# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot
# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic
# Anything higher than this threshold will be marked as toxic and commented on
sentimentBotToxicityThreshold: .7
# *Required* Comment to reply with
sentimentBotReplyComment: >
Please be sure to review the [code of conduct](https://github.com/nlohmann/json/blob/develop/CODE_OF_CONDUCT.md) and be respectful of other users. cc/ @nlohmann
# Configuration for request-info - https://github.com/behaviorbot/request-info
# *Required* Comment to reply with
requestInfoReplyComment: >
We would appreciate it if you could provide us with more info about this issue or pull request! Please check the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) and the [pull request template](https://github.com/nlohmann/json/blob/develop/.github/PULL_REQUEST_TEMPLATE.md).
# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
requestInfoLabelToAdd: "state: needs more info"
+17
View File
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: "state: stale"
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
+24
View File
@@ -0,0 +1,24 @@
json_unit
json_benchmarks
json_benchmarks_simple
fuzz-testing
*.dSYM
*.o
*.gcno
*.gcda
build
build_coverage
clang_analyze_build
doc/xml
doc/html
me.nlohmann.json.docset
benchmarks/files/numbers/*.json
.idea
cmake-build-debug
test/test-*
+327
View File
@@ -0,0 +1,327 @@
#########################
# project configuration #
#########################
# C++ project
language: cpp
dist: trusty
sudo: required
group: edge
###################
# global settings #
###################
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA="
################
# build matrix #
################
matrix:
include:
# Valgrind
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- CMAKE_OPTIONS=-DJSON_Valgrind=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'valgrind', 'ninja-build']
# clang sanitizer
- os: linux
compiler: clang
env:
- COMPILER=clang++-5.0
- CMAKE_OPTIONS=-DJSON_Sanitizer=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']
# cppcheck
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=cppcheck
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'cppcheck', 'ninja-build']
after_success:
- make cppcheck
# no exceptions
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- CMAKE_OPTIONS=-DJSON_NoExceptions=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ninja-build']
# check amalgamation
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=amalgamation
- MULTIPLE_HEADERS=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'astyle', 'ninja-build']
after_success:
- make check-amalgamation
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', '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'
env:
- COMPILER=g++-4.9
- CMAKE_OPTIONS=-DJSON_Coverage=ON
- MULTIPLE_HEADERS=ON
# Coverity (only for branch coverity_scan)
- os: linux
compiler: clang
before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
coverity_scan:
project:
name: "nlohmann/json"
description: "Build submitted via Travis CI"
notification_email: niels.lohmann@gmail.com
build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .."
build_command: "make -C coverity_build"
branch_pattern: coverity_scan
env:
- SPECIAL=coverity
- COMPILER=clang++-3.6
# OSX / Clang
- os: osx
osx_image: xcode6.4
- os: osx
osx_image: xcode7.3
- os: osx
osx_image: xcode8
- os: osx
osx_image: xcode8.1
- os: osx
osx_image: xcode8.2
- 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
- os: osx
osx_image: xcode9.4
# Linux / GCC
- os: linux
compiler: gcc
env: COMPILER=g++-4.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-5
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-6
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-7
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7', 'ninja-build']
- os: linux
compiler: gcc
env: COMPILER=g++-8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8', 'ninja-build']
- os: linux
compiler: gcc
env:
- COMPILER=g++-8
- CXXFLAGS=-std=c++17
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8', 'ninja-build']
# Linux / Clang
- os: linux
compiler: clang
env: COMPILER=clang++-3.5
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['g++-6', 'clang-3.5', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-3.6
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['g++-6', 'clang-3.6', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-3.7
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
packages: ['g++-6', 'clang-3.7', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-3.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.8', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-3.9
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6', 'clang-3.9', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-4.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
packages: ['g++-6', 'clang-4.0', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-5.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
packages: ['g++-6', 'clang-5.0', 'ninja-build']
- os: linux
compiler: clang
env: COMPILER=clang++-6.0
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0']
packages: ['g++-6', 'clang-6.0', 'ninja-build']
- os: linux
compiler: clang
env:
- COMPILER=clang++-6.0
- CXXFLAGS=-std=c++1z
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0']
packages: ['g++-6', 'clang-6.0', 'ninja-build']
################
# build script #
################
script:
# get CMake and Ninja (only for systems with brew - macOS)
- |
if [[ (-x $(which brew)) ]]; then
brew update
brew install cmake ninja
brew upgrade cmake
cmake --version
fi
# make sure CXX is correctly set
- if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi
# 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
- cd ..
# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
brew update ;
brew tap nlohmann/json ;
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
fi
-1
View File
File diff suppressed because one or more lines are too long
+123
View File
@@ -0,0 +1,123 @@
cmake_minimum_required(VERSION 3.8)
##
## PROJECT
## name and version
##
project(nlohmann_json VERSION 3.2.0 LANGUAGES CXX)
##
## INCLUDE
##
##
include(ExternalProject)
##
## OPTIONS
##
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
##
## CONFIGURATION
##
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_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}")
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
if (JSON_MultipleHeaders)
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
message(STATUS "Using the multi-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
else()
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/")
message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}")
endif()
##
## TARGET
## create target and add include path
##
add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME})
target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11)
target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
)
## add debug view definition file for msvc (natvis)
if (MSVC)
set(NLOHMANN_ADD_NATVIS TRUE)
set(NLOHMANN_NATVIS_FILE "nlohmann_json.natvis")
target_sources(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<INSTALL_INTERFACE:${NLOHMANN_NATVIS_FILE}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_NATVIS_FILE}>
)
endif()
##
## TESTS
## create and configure the unit test target
##
include(CTest) #adds option BUILD_TESTING (default ON)
if(BUILD_TESTING AND JSON_BuildTests)
enable_testing()
add_subdirectory(test)
endif()
##
## INSTALL
## 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
)
configure_package_config_file(
${NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE}
${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE}
INSTALL_DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
)
install(
DIRECTORY ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}
DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
)
install(
FILES ${NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE} ${NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE}
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
)
if (NLOHMANN_ADD_NATVIS)
install(
FILES ${NLOHMANN_NATVIS_FILE}
DESTINATION .
)
endif()
export(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE ${NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE}
)
install(
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
INCLUDES DESTINATION ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}
)
install(
EXPORT ${NLOHMANN_JSON_TARGETS_EXPORT_NAME}
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${NLOHMANN_JSON_CONFIG_INSTALL_DIR}
)
+46
View File
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mail@nlohmann.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+1209
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-2018 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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+334
View File
@@ -0,0 +1,334 @@
.PHONY: pretty clean ChangeLog.md
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/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
# 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"
@echo "doctest - compile example files and check their output"
@echo "fuzz_testing - prepare fuzz testing of the JSON parser"
@echo "fuzz_testing_cbor - prepare fuzz testing of the CBOR parser"
@echo "fuzz_testing_msgpack - prepare fuzz testing of the MessagePack parser"
@echo "fuzz_testing_ubjson - prepare fuzz testing of the UBJSON parser"
@echo "json_unit - create single-file test executable"
@echo "pedantic_clang - run Clang with maximal warning flags"
@echo "pedantic_gcc - run GCC with maximal warning flags"
@echo "pretty - beautify code with Artistic Style"
@echo "run_benchmarks - build and run benchmarks"
##########################################################################
# unit tests
##########################################################################
# build unit tests
json_unit:
@$(MAKE) json_unit -C test
# run unit tests
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:
mkdir build_coverage
cd build_coverage ; CXX=g++-7 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON
cd build_coverage ; ninja
cd build_coverage ; ctest -E '.*_default' -j10
cd build_coverage ; ninja lcov_html
open build_coverage/test/html/index.html
##########################################################################
# documentation tests
##########################################################################
# compile example files and check output
doctest:
$(MAKE) check_output -C doc
##########################################################################
# warning detector
##########################################################################
# 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-padded: padding is nothing to warn about
pedantic_clang:
$(MAKE) json_unit CXXFLAGS="\
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
-Werror \
-Weverything \
-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-switch-enum -Wno-covered-switch-default \
-Wno-padded"
# calling GCC with most warnings
pedantic_gcc:
$(MAKE) json_unit CXXFLAGS="\
-std=c++11 \
-Wno-deprecated-declarations \
-Werror \
-Wall -Wpedantic -Wextra \
-Walloca \
-Warray-bounds=2 \
-Wcast-qual -Wcast-align \
-Wchar-subscripts \
-Wconditionally-supported \
-Wconversion \
-Wdate-time \
-Wdeprecated \
-Wdisabled-optimization \
-Wdouble-promotion \
-Wduplicated-branches \
-Wduplicated-cond \
-Wformat-overflow=2 \
-Wformat-signedness \
-Wformat-truncation=2 \
-Wformat=2 \
-Wno-ignored-qualifiers \
-Wimplicit-fallthrough=5 \
-Wlogical-op \
-Wmissing-declarations \
-Wmissing-format-attribute \
-Wmissing-include-dirs \
-Wnoexcept \
-Wnonnull \
-Wnull-dereference \
-Wold-style-cast \
-Woverloaded-virtual \
-Wparentheses \
-Wplacement-new=2 \
-Wredundant-decls \
-Wreorder \
-Wrestrict \
-Wshadow=global \
-Wshift-overflow=2 \
-Wsign-conversion \
-Wsign-promo \
-Wsized-deallocation \
-Wstrict-overflow=5 \
-Wsuggest-attribute=const \
-Wsuggest-attribute=format \
-Wsuggest-attribute=noreturn \
-Wsuggest-attribute=pure \
-Wsuggest-final-methods \
-Wsuggest-final-types \
-Wsuggest-override \
-Wtrigraphs \
-Wundef \
-Wuninitialized -Wunknown-pragmas \
-Wunused \
-Wunused-const-variable=2 \
-Wunused-macros \
-Wunused-parameter \
-Wuseless-cast \
-Wvariadic-macros"
##########################################################################
# benchmarks
##########################################################################
run_benchmarks:
mkdir build_benchmarks
cd build_benchmarks ; cmake ../benchmarks
cd build_benchmarks ; make
cd build_benchmarks ; ./json_benchmarks
##########################################################################
# fuzzing
##########################################################################
# the overall fuzz testing target
fuzz_testing:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_afl_fuzzer -C test CXX=afl-clang++
mv test/parse_afl_fuzzer fuzz-testing/fuzzer
find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_cbor:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_cbor_fuzzer -C test CXX=afl-clang++
mv test/parse_cbor_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.cbor | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_msgpack:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_msgpack_fuzzer -C test CXX=afl-clang++
mv test/parse_msgpack_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.msgpack | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzz_testing_ubjson:
rm -fr fuzz-testing
mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out
$(MAKE) parse_ubjson_fuzzer -C test CXX=afl-clang++
mv test/parse_ubjson_fuzzer fuzz-testing/fuzzer
find test/data -size -5k -name *.ubjson | xargs -I{} cp "{}" fuzz-testing/testcases
@echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer"
fuzzing-start:
afl-fuzz -S fuzzer1 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer2 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer3 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer4 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer5 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer6 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -S fuzzer7 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer > /dev/null &
afl-fuzz -M fuzzer0 -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzzer
fuzzing-stop:
-killall fuzzer
-killall afl-fuzz
##########################################################################
# static analyzer
##########################################################################
# call cppcheck on the main header file
cppcheck:
cppcheck --enable=warning --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1
# compile and check with Clang Static Analyzer
clang_analyze:
rm -fr clang_analyze_build
mkdir clang_analyze_build
cd clang_analyze_build ; CCC_CXX=/Users/niels/Documents/projects/llvm-clang/local/bin/clang++ /Users/niels/Documents/projects/llvm-clang/local/bin/scan-build cmake ..
/Users/niels/Documents/projects/llvm-clang/local/bin/scan-build -enable-checker alpha.core.DynamicTypeChecker,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.cplusplus.DeleteWithNonVirtualDtor,alpha.cplusplus.IteratorRange,alpha.cplusplus.MisusedMovedObject,alpha.security.ArrayBoundV2,alpha.core.Conversion --use-c++=/Users/niels/Documents/projects/llvm-clang/local/bin/clang++ --view -analyze-headers -o clang_analyze_build/report.html make -j10 -C clang_analyze_build
##########################################################################
# maintainer targets
##########################################################################
# pretty printer
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
# create single header file
amalgamate: $(AMALGAMATED_FILE)
$(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-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-single-includes:
for x in $(SRCS); do \
echo "#include <$$x>\nint main() {}\n" | sed 's|include/||' > single_include_test.cpp; \
$(CXX) $(CXXFLAGS) -Iinclude -std=c++11 single_include_test.cpp -o single_include_test; \
rm single_include_test.cpp single_include_test; \
done
##########################################################################
# changelog
##########################################################################
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
##########################################################################
# release
##########################################################################
release:
mkdir release_files
zip -9 -r include.zip include/*
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
cd release_files ; shasum -a 256 json.hpp > hashes.txt
cd release_files ; shasum -a 256 include.zip >> hashes.txt
+1123
View File
File diff suppressed because it is too large Load Diff
-35
View File
@@ -1,35 +0,0 @@
# <small>nlohmann::</small>adl_serializer
```cpp
template<typename, typename>
struct adl_serializer;
```
Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose
`to_json`/`from_json` functions from the types' namespaces.
It is implemented similarly to
```cpp
template<typename ValueType>
struct adl_serializer {
template<typename BasicJsonType>
static void to_json(BasicJsonType& j, const T& value) {
// calls the "to_json" method in T's namespace
}
template<typename BasicJsonType>
static void from_json(const BasicJsonType& j, T& value) {
// same thing, but with the "from_json" method
}
};
```
## Member functions
- [**from_json**](from_json.md) - convert a JSON value to any value type
- [**to_json**](to_json.md) - convert any value type to a JSON value
## Version history
- Added in version 2.1.0.
-74
View File
@@ -1,74 +0,0 @@
# <small>nlohmann::adl_serializer::</small>from_json
```cpp
// (1)
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
// (2)
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
```
This function is usually called by the [`get()`](../basic_json/get.md) function of the [basic_json](../basic_json/index.md)
class (either explicitly or via the conversion operators).
1. This function is chosen for default-constructible value types.
2. This function is chosen for value types which are not default-constructible.
## Parameters
`j` (in)
: JSON value to read from
`val` (out)
: value to write to
## Return value
1. (none) -- the converted value is written to the output parameter `val`.
2. the JSON value `j` converted to `TargetType`
## Examples
??? example "Example: (1) Default-constructible type"
The example below shows how a `from_json` function can be implemented for a user-defined type. This function is
called by the `adl_serializer` when `get<ns::person>()` is called.
```cpp
--8<-- "examples/from_json__default_constructible.cpp"
```
Output:
```json
--8<-- "examples/from_json__default_constructible.output"
```
??? example "Example: (2) Non-default-constructible type"
The example below shows how a `from_json` is implemented as part of a specialization of the `adl_serializer` to
realize the conversion of a non-default-constructible type.
```cpp
--8<-- "examples/from_json__non_default_constructible.cpp"
```
Output:
```json
--8<-- "examples/from_json__non_default_constructible.output"
```
## See also
- [to_json](to_json.md)
## Version history
- Added in version 2.1.0.
File diff suppressed because one or more lines are too long
-157
View File
@@ -1,157 +0,0 @@
# nlohmann::adl_serializer::from_json
```
// (1)
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
// (2)
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
```
This function is usually called by the [`get()`](https://json.nlohmann.me/api/basic_json/get/index.md) function of the [basic_json](https://json.nlohmann.me/api/basic_json/index.md) class (either explicitly or via the conversion operators).
1. This function is chosen for default-constructible value types.
1. This function is chosen for value types which are not default-constructible.
## Parameters
`j` (in) : JSON value to read from
`val` (out) : value to write to
## Return value
1. (none) -- the converted value is written to the output parameter `val`.
1. the JSON value `j` converted to `TargetType`
## Examples
Example: (1) Default-constructible type
The example below shows how a `from_json` function can be implemented for a user-defined type. This function is called by the `adl_serializer` when `get<ns::person>()` is called.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace ns
{
// a simple struct to model a person
struct person
{
std::string name;
std::string address;
int age;
};
} // namespace ns
namespace ns
{
void from_json(const json& j, person& p)
{
j.at("name").get_to(p.name);
j.at("address").get_to(p.address);
j.at("age").get_to(p.age);
}
} // namespace ns
int main()
{
json j;
j["name"] = "Ned Flanders";
j["address"] = "744 Evergreen Terrace";
j["age"] = 60;
auto p = j.get<ns::person>();
std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
}
```
Output:
```
Ned Flanders (60) lives in 744 Evergreen Terrace
```
Example: (2) Non-default-constructible type
The example below shows how a `from_json` is implemented as part of a specialization of the `adl_serializer` to realize the conversion of a non-default-constructible type.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace ns
{
// a simple struct to model a person (not default constructible)
struct person
{
person(std::string n, std::string a, int aa)
: name(std::move(n)), address(std::move(a)), age(aa)
{}
std::string name;
std::string address;
int age;
};
} // namespace ns
namespace nlohmann
{
template <>
struct adl_serializer<ns::person>
{
static ns::person from_json(const json& j)
{
return {j.at("name"), j.at("address"), j.at("age")};
}
// Here's the catch! You must provide a to_json method! Otherwise, you
// will not be able to convert person to json, since you fully
// specialized adl_serializer on that type
static void to_json(json& j, ns::person p)
{
j["name"] = p.name;
j["address"] = p.address;
j["age"] = p.age;
}
};
} // namespace nlohmann
int main()
{
json j;
j["name"] = "Ned Flanders";
j["address"] = "744 Evergreen Terrace";
j["age"] = 60;
auto p = j.get<ns::person>();
std::cout << p.name << " (" << p.age << ") lives in " << p.address << std::endl;
}
```
Output:
```
Ned Flanders (60) lives in 744 Evergreen Terrace
```
## See also
- [to_json](https://json.nlohmann.me/api/adl_serializer/to_json/index.md)
## Version history
- Added in version 2.1.0.
File diff suppressed because one or more lines are too long
-34
View File
@@ -1,34 +0,0 @@
# nlohmann::adl_serializer
```
template<typename, typename>
struct adl_serializer;
```
Serializer that uses ADL ([Argument-Dependent Lookup](https://en.cppreference.com/w/cpp/language/adl)) to choose `to_json`/`from_json` functions from the types' namespaces.
It is implemented similarly to
```
template<typename ValueType>
struct adl_serializer {
template<typename BasicJsonType>
static void to_json(BasicJsonType& j, const T& value) {
// calls the "to_json" method in T's namespace
}
template<typename BasicJsonType>
static void from_json(const BasicJsonType& j, T& value) {
// same thing, but with the "from_json" method
}
};
```
## Member functions
- [**from_json**](https://json.nlohmann.me/api/adl_serializer/from_json/index.md) - convert a JSON value to any value type
- [**to_json**](https://json.nlohmann.me/api/adl_serializer/to_json/index.md) - convert any value type to a JSON value
## Version history
- Added in version 2.1.0.
-43
View File
@@ -1,43 +0,0 @@
# <small>nlohmann::adl_serializer::</small>to_json
```cpp
template<typename BasicJsonType, typename TargetType = ValueType>
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
```
This function is usually called by the constructors of the [basic_json](../basic_json/index.md) class.
## Parameters
`j` (out)
: JSON value to write to
`val` (in)
: value to read from
## Examples
??? example
The example below shows how a `to_json` function can be implemented for a user-defined type. This function is called
by the `adl_serializer` when the constructor `basic_json(ns::person)` is called.
```cpp
--8<-- "examples/to_json.cpp"
```
Output:
```json
--8<-- "examples/to_json.output"
```
## See also
- [from_json](from_json.md)
## Version history
- Added in version 2.1.0.
File diff suppressed because one or more lines are too long
-71
View File
@@ -1,71 +0,0 @@
# nlohmann::adl_serializer::to_json
```
template<typename BasicJsonType, typename TargetType = ValueType>
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
```
This function is usually called by the constructors of the [basic_json](https://json.nlohmann.me/api/basic_json/index.md) class.
## Parameters
`j` (out) : JSON value to write to
`val` (in) : value to read from
## Examples
Example
The example below shows how a `to_json` function can be implemented for a user-defined type. This function is called by the `adl_serializer` when the constructor `basic_json(ns::person)` is called.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace ns
{
// a simple struct to model a person
struct person
{
std::string name;
std::string address;
int age;
};
} // namespace ns
namespace ns
{
void to_json(json& j, const person& p)
{
j = json{ {"name", p.name}, {"address", p.address}, {"age", p.age} };
}
} // namespace ns
int main()
{
ns::person p = {"Ned Flanders", "744 Evergreen Terrace", 60};
json j = p;
std::cout << j << std::endl;
}
```
Output:
```
{"address":"744 Evergreen Terrace","age":60,"name":"Ned Flanders"}
```
## See also
- [from_json](https://json.nlohmann.me/api/adl_serializer/from_json/index.md)
## Version history
- Added in version 2.1.0.
-338
View File
@@ -1,338 +0,0 @@
# <small>nlohmann::</small>basic_json
<small>Defined in header `<nlohmann/json.hpp>`</small>
```cpp
template<
template<typename U, typename V, typename... Args> class ObjectType = std::map,
template<typename U, typename... Args> 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<typename U> class AllocatorType = std::allocator,
template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer,
class BinaryType = std::vector<std::uint8_t>,
class CustomBaseClass = void
>
class basic_json;
```
## Template parameters
| Template parameter | Description | Derived type |
|----------------------|---------------------------------------------------------------------------|---------------------------------------------|
| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) |
| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) |
| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) |
| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) |
| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) |
| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) |
| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) |
| `AllocatorType` | type of the allocator to use | |
| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) |
| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) |
| `CustomBaseClass` | extension point for user code | [`json_base_class_t`](json_base_class_t.md) |
## Specializations
- [**json**](../json.md) - default specialization
- [**ordered_json**](../ordered_json.md) - a specialization that maintains the insertion order of object keys
## Iterator invalidation
All operations that add values to an **array** ([`push_back`](push_back.md) , [`operator+=`](operator+=.md),
[`emplace_back`](emplace_back.md), [`insert`](insert.md), and [`operator[]`](operator%5B%5D.md) for a non-existing
index) can yield a reallocation, in which case all iterators (including the [`end()`](end.md) iterator) and all
references to the elements are invalidated.
For [`ordered_json`](../ordered_json.md), also all operations that add a value to an **object**
([`push_back`](push_back.md), [`operator+=`](operator+=.md), [`emplace`](emplace.md), [`insert`](insert.md),
[`update`](update.md), and [`operator[]`](operator%5B%5D.md) for a non-existing key) can yield a reallocation, in
which case all iterators (including the [`end()`](end.md) iterator) and all references to the elements are invalidated.
## Requirements
The class satisfies the following concept requirements:
### Basic
- [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): JSON values can be
default-constructed. The result will be a JSON null value.
- [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): A JSON value can be constructed
from an rvalue argument.
- [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): A JSON value can be
copy-constructed from an lvalue expression.
- [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): A JSON value can be assigned from an
rvalue argument.
- [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): A JSON value can be copy-assigned from
an lvalue expression.
- [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): JSON values can be destructed.
### Layout
- [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): JSON values have
[standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): All non-static data
members are private and standard layout types, the class has no virtual functions or (virtual) base classes.
### Library-wide
- [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): JSON values can be compared with
`==`, see [`operator==`](operator_eq.md).
- [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): JSON values can be compared with
`<`, see [`operator<`](operator_le.md).
- [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): Any JSON lvalue or rvalue of can be swapped with
any lvalue or rvalue of other compatible types, using unqualified function `swap`.
- [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): JSON values can be compared against
`std::nullptr_t` objects which are used to model the `null` value.
### Container
- [Container](https://en.cppreference.com/w/cpp/named_req/Container): JSON values can be used like STL containers and
provide iterator access.
- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer): JSON values can be used like
STL containers and provide reverse iterator access.
## Member types
- [**adl_serializer**](../adl_serializer/index.md) - the default serializer
- [**value_t**](value_t.md) - the JSON type enumeration
- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
- **initializer_list_t** - type for initializer lists of `basic_json` values
- [**input_format_t**](input_format_t.md) - type to choose the format to parse
- [**json_sax_t**](../json_sax/index.md) - type for SAX events
### Exceptions
- [**exception**](exception.md) - general exception of the `basic_json` class
- [**parse_error**](parse_error.md) - exception indicating a parse error
- [**invalid_iterator**](invalid_iterator.md) - exception indicating errors with iterators
- [**type_error**](type_error.md) - exception indicating executing a member function with a wrong type
- [**out_of_range**](out_of_range.md) - exception indicating access out of the defined range
- [**other_error**](other_error.md) - exception indicating other library errors
### Container types
| Type | Definition |
|--------------------------|-----------------------------------------------------------------------------------------------------------|
| `value_type` | `#!cpp basic_json` |
| `reference` | `#!cpp value_type&` |
| `const_reference` | `#!cpp const value_type&` |
| `difference_type` | `#!cpp std::ptrdiff_t` |
| `size_type` | `#!cpp std::size_t` |
| `allocator_type` | `#!cpp AllocatorType<basic_json>` |
| `pointer` | `#!cpp std::allocator_traits<allocator_type>::pointer` |
| `const_pointer` | `#!cpp std::allocator_traits<allocator_type>::const_pointer` |
| `iterator` | [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) |
| `const_iterator` | constant [LegacyBidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator) |
| `reverse_iterator` | reverse iterator, derived from `iterator` |
| `const_reverse_iterator` | reverse iterator, derived from `const_iterator` |
| `iteration_proxy` | helper type for [`items`](items.md) function |
### JSON value data types
- [**array_t**](array_t.md) - type for arrays
- [**binary_t**](binary_t.md) - type for binary arrays
- [**boolean_t**](boolean_t.md) - type for booleans
- [**default_object_comparator_t**](default_object_comparator_t.md) - default comparator for objects
- [**number_float_t**](number_float_t.md) - type for numbers (floating-point)
- [**number_integer_t**](number_integer_t.md) - type for numbers (integer)
- [**number_unsigned_t**](number_unsigned_t.md) - type for numbers (unsigned)
- [**object_comparator_t**](object_comparator_t.md) - comparator for objects
- [**object_t**](object_t.md) - type for objects
- [**string_t**](string_t.md) - type for strings
### Parser callback
- [**parse_event_t**](parse_event_t.md) - parser event types
- [**parser_callback_t**](parser_callback_t.md) - per-element parser callback type
## Member functions
- [(constructor)](basic_json.md)
- [(destructor)](~basic_json.md)
- [**operator=**](operator=.md) - copy assignment
- [**array**](array.md) (_static_) - explicitly create an array
- [**binary**](binary.md) (_static_) - explicitly create a binary array
- [**object**](object.md) (_static_) - explicitly create an object
### Object inspection
Functions to inspect the type of a JSON value.
- [**type**](type.md) - return the type of the JSON value
- [**operator value_t**](operator_value_t.md) - return the type of the JSON value
- [**type_name**](type_name.md) - return the type as string
- [**is_primitive**](is_primitive.md) - return whether the type is primitive
- [**is_structured**](is_structured.md) - return whether the type is structured
- [**is_null**](is_null.md) - return whether the value is null
- [**is_boolean**](is_boolean.md) - return whether the value is a boolean
- [**is_number**](is_number.md) - return whether the value is a number
- [**is_number_integer**](is_number_integer.md) - return whether the value is an integer number
- [**is_number_unsigned**](is_number_unsigned.md) - return whether the value is an unsigned integer number
- [**is_number_float**](is_number_float.md) - return whether the value is a floating-point number
- [**is_object**](is_object.md) - return whether the value is an object
- [**is_array**](is_array.md) - return whether the value is an array
- [**is_string**](is_string.md) - return whether the value is a string
- [**is_binary**](is_binary.md) - return whether the value is a binary array
- [**is_discarded**](is_discarded.md) - return whether the value is discarded
Optional functions to access the [diagnostic positions](../macros/json_diagnostic_positions.md).
- [**start_pos**](start_pos.md) - return the start position of the value
- [**end_pos**](end_pos.md) - return the one past the end position of the value
### Value access
Direct access to the stored value of a JSON value.
- [**get**](get.md) - get a value
- [**get_to**](get_to.md) - get a value and write it to a destination
- [**get_ptr**](get_ptr.md) - get a pointer value
- [**get_ref**](get_ref.md) - get a reference value
- [**operator ValueType**](operator_ValueType.md) - get a value
- [**get_binary**](get_binary.md) - get a binary value
### Element access
Access to the JSON value
- [**at**](at.md) - access specified element with bounds checking
- [**operator[]**](operator[].md) - access specified element
- [**value**](value.md) - access specified object element with default value
- [**front**](front.md) - access the first element
- [**back**](back.md) - access the last element
### Lookup
- [**find**](find.md) - find an element in a JSON object
- [**count**](count.md) - returns the number of occurrences of a key in a JSON object
- [**contains**](contains.md) - check the existence of an element in a JSON object
### Iterators
- [**begin**](begin.md) - returns an iterator to the first element
- [**cbegin**](cbegin.md) - returns a const iterator to the first element
- [**end**](end.md) - returns an iterator to one past the last element
- [**cend**](cend.md) - returns a const iterator to one past the last element
- [**rbegin**](rbegin.md) - returns an iterator to the reverse-beginning
- [**rend**](rend.md) - returns an iterator to the reverse-end
- [**crbegin**](crbegin.md) - returns a const iterator to the reverse-beginning
- [**crend**](crend.md) - returns a const iterator to the reverse-end
- [**items**](items.md) - wrapper to access iterator member functions in range-based for
### Capacity
- [**empty**](empty.md) - checks whether the container is empty
- [**size**](size.md) - returns the number of elements
- [**max_size**](max_size.md) - returns the maximum possible number of elements
### Modifiers
- [**clear**](clear.md) - clears the contents
- [**push_back**](push_back.md) - add a value to an array/object
- [**operator+=**](operator+=.md) - add a value to an array/object
- [**emplace_back**](emplace_back.md) - add a value to an array
- [**emplace**](emplace.md) - add a value to an object if a key does not exist
- [**erase**](erase.md) - remove elements
- [**insert**](insert.md) - inserts elements
- [**update**](update.md) - updates a JSON object from another object, overwriting existing keys
- [**swap**](swap.md) - exchanges the values
### Lexicographical comparison operators
- [**operator==**](operator_eq.md) - comparison: equal
- [**operator!=**](operator_ne.md) - comparison: not equal
- [**operator<**](operator_lt.md) - comparison: less than
- [**operator>**](operator_gt.md) - comparison: greater than
- [**operator<=**](operator_le.md) - comparison: less than or equal
- [**operator>=**](operator_ge.md) - comparison: greater than or equal
- [**operator<=>**](operator_spaceship.md) - comparison: 3-way
### Serialization / Dumping
- [**dump**](dump.md) - serialization
### Deserialization / Parsing
- [**parse**](parse.md) (_static_) - deserialize from a compatible input
- [**accept**](accept.md) (_static_) - check if the input is valid JSON
- [**sax_parse**](sax_parse.md) (_static_) - generate SAX events
### JSON Pointer functions
- [**flatten**](flatten.md) - return flattened JSON value
- [**unflatten**](unflatten.md) - unflatten a previously flattened JSON value
### JSON Patch functions
- [**patch**](patch.md) - applies a JSON patch
- [**patch_inplace**](patch_inplace.md) - applies a JSON patch in place
- [**diff**](diff.md) (_static_) - creates a diff as a JSON patch
### JSON Merge Patch functions
- [**merge_patch**](merge_patch.md) - applies a JSON Merge Patch
## Static functions
- [**meta**](meta.md) - returns version information on the library
- [**get_allocator**](get_allocator.md) - returns the allocator associated with the container
### Binary formats
- [**from_bjdata**](from_bjdata.md) (_static_) - create a JSON value from an input in BJData format
- [**from_bson**](from_bson.md) (_static_) - create a JSON value from an input in BSON format
- [**from_cbor**](from_cbor.md) (_static_) - create a JSON value from an input in CBOR format
- [**from_msgpack**](from_msgpack.md) (_static_) - create a JSON value from an input in MessagePack format
- [**from_ubjson**](from_ubjson.md) (_static_) - create a JSON value from an input in UBJSON format
- [**to_bjdata**](to_bjdata.md) (_static_) - create a BJData serialization of a given JSON value
- [**to_bson**](to_bson.md) (_static_) - create a BSON serialization of a given JSON value
- [**to_cbor**](to_cbor.md) (_static_) - create a CBOR serialization of a given JSON value
- [**to_msgpack**](to_msgpack.md) (_static_) - create a MessagePack serialization of a given JSON value
- [**to_ubjson**](to_ubjson.md) (_static_) - create a UBJSON serialization of a given JSON value
## Non-member functions
- [**operator<<(std::ostream&)**](../operator_ltlt.md) - serialize to stream
- [**operator>>(std::istream&)**](../operator_gtgt.md) - deserialize from stream
- [**to_string**](to_string.md) - user-defined `to_string` function for JSON values
- [**format_as**](format_as.md) - user-defined `format_as` function for JSON values (fmt support)
## Literals
- [**operator""_json**](../operator_literal_json.md) - user-defined string literal for JSON values
## Helper classes
- [**std::formatter&lt;basic_json&gt;**](std_formatter.md) - make JSON values formattable with `std::format`
- [**std::hash&lt;basic_json&gt;**](std_hash.md) - return a hash value for a JSON object
- [**std::swap&lt;basic_json&gt;**](std_swap.md) - exchanges the values of two JSON objects
## Examples
??? example
The example shows how the library is used.
```cpp
--8<-- "examples/README.cpp"
```
Output:
```json
--8<-- "examples/README.output"
```
## See also
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259)
## Version history
- Added in version 1.0.0.
-131
View File
@@ -1,131 +0,0 @@
# <small>nlohmann::basic_json::</small>accept
```cpp
// (1)
template<typename InputType>
static bool accept(InputType&& i,
const bool ignore_comments = false,
const bool ignore_trailing_commas = false);
// (2)
template<typename IteratorType, typename SentinelType = IteratorType>
static bool accept(IteratorType first, SentinelType last,
const bool ignore_comments = false,
const bool ignore_trailing_commas = false);
```
Checks whether the input is valid JSON.
1. Reads from a compatible input.
2. Reads from a pair of character iterators, or an iterator and a sentinel of a different type (C++20 ranges support)
The value_type of the iterator must be an integral type with a size of 1, 2, or 4 bytes, which will be interpreted
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
the iterator type with `operator!=`.
Unlike the [`parse()`](parse.md) function, this function neither throws an exception in case of invalid JSON input
(i.e., a parse error) nor creates diagnostic information.
## Template parameters
`InputType`
: A compatible input, for instance:
- an `std::istream` object
- a `#!c FILE` pointer (throws if null)
- a C-style array of characters
- a pointer to a null-terminated string of single byte characters (throws if null)
- a `std::string`
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
`IteratorType`
: a compatible iterator type, for instance.
- a pair of `std::string::iterator` or `std::vector<std::uint8_t>::iterator`
- a pair of pointers such as `ptr` and `ptr + len`
`SentinelType`
: defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
- a custom sentinel type for C++20 ranges
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
## Parameters
`i` (in)
: Input to parse from.
`ignore_comments` (in)
: whether comments should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
(`#!cpp false`); (optional, `#!cpp false` by default)
`ignore_trailing_commas` (in)
: whether trailing commas in arrays or objects should be ignored and treated like whitespace (`#!cpp true`) or yield a parse error
(`#!cpp false`); (optional, `#!cpp false` by default)
`first` (in)
: iterator to the start of the character range
`last` (in)
: iterator to the end of the character range, or a sentinel value that compares equal to the end iterator with `operator!=`
## Return value
Whether the input is valid JSON.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Exceptions
Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an empty input like a null `#!c FILE*` or `#!c char*` pointer.
## Complexity
Linear in the length of the input. The parser is a predictive LL(1) parser.
## Notes
A UTF-8 byte order mark is silently ignored.
## Examples
??? example
The example below demonstrates the `accept()` function reading from a string.
```cpp
--8<-- "examples/accept__string.cpp"
```
Output:
```json
--8<-- "examples/accept__string.output"
```
## See also
- [parse](parse.md) - deserialize from a compatible input
- [sax_parse](sax_parse.md) - parse input using the SAX interface
- [operator>>](../operator_gtgt.md) - deserialize from stream
## Version history
- Added in version 3.0.0.
- Ignoring comments via `ignore_comments` added in version 3.9.0.
- Changed [runtime assertion](../../features/assertions.md) in case of `FILE*` null pointers to exception in version 3.12.0.
- Added `ignore_trailing_commas` in version 3.13.0.
- Extended container support (1) to include types with lvalue-only ADL `begin`/`end` (matching `std::begin`/`std::end` semantics) in version 3.13.0.
- Extended overload (2) to accept heterogeneous iterator+sentinel pairs (C++20 ranges support) in version 3.13.0.
!!! warning "Deprecation"
Overload (2) replaces calls to `accept` with a pair of iterators as their first parameter which has been
deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like
`#!cpp accept({ptr, ptr+len}, ...);` with `#!cpp accept(ptr, ptr+len, ...);`.
You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated
function.
File diff suppressed because one or more lines are too long
-147
View File
@@ -1,147 +0,0 @@
# nlohmann::basic_json::accept
```
// (1)
template<typename InputType>
static bool accept(InputType&& i,
const bool ignore_comments = false,
const bool ignore_trailing_commas = false);
// (2)
template<typename IteratorType, typename SentinelType = IteratorType>
static bool accept(IteratorType first, SentinelType last,
const bool ignore_comments = false,
const bool ignore_trailing_commas = false);
```
Checks whether the input is valid JSON.
1. Reads from a compatible input.
1. Reads from a pair of character iterators, or an iterator and a sentinel of a different type (C++20 ranges support)
The value_type of the iterator must be an integral type with a size of 1, 2, or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to the iterator type with `operator!=`.
Unlike the [`parse()`](https://json.nlohmann.me/api/basic_json/parse/index.md) function, this function neither throws an exception in case of invalid JSON input (i.e., a parse error) nor creates diagnostic information.
## Template parameters
`InputType` : A compatible input, for instance:
```
- an `std::istream` object
- a `FILE` pointer (throws if null)
- a C-style array of characters
- a pointer to a null-terminated string of single byte characters (throws if null)
- a `std::string`
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
```
`IteratorType` : a compatible iterator type, for instance.
```
- a pair of `std::string::iterator` or `std::vector<std::uint8_t>::iterator`
- a pair of pointers such as `ptr` and `ptr + len`
```
`SentinelType` : defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
```
- a custom sentinel type for C++20 ranges
- `std::default_sentinel_t`, when `IteratorType` is `std::counted_iterator`
```
## Parameters
`i` (in) : Input to parse from.
`ignore_comments` (in) : whether comments should be ignored and treated like whitespace (`true`) or yield a parse error (`false`); (optional, `false` by default)
`ignore_trailing_commas` (in) : whether trailing commas in arrays or objects should be ignored and treated like whitespace (`true`) or yield a parse error (`false`); (optional, `false` by default)
`first` (in) : iterator to the start of the character range
`last` (in) : iterator to the end of the character range, or a sentinel value that compares equal to the end iterator with `operator!=`
## Return value
Whether the input is valid JSON.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Exceptions
Throws [`parse_error.101`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error101) in case of an empty input like a null `FILE*` or `char*` pointer.
## Complexity
Linear in the length of the input. The parser is a predictive LL(1) parser.
## Notes
A UTF-8 byte order mark is silently ignored.
## Examples
Example
The example below demonstrates the `accept()` function reading from a string.
```
#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';
}
```
Output:
```
true false
```
## See also
- [parse](https://json.nlohmann.me/api/basic_json/parse/index.md) - deserialize from a compatible input
- [sax_parse](https://json.nlohmann.me/api/basic_json/sax_parse/index.md) - parse input using the SAX interface
- [operator>>](https://json.nlohmann.me/api/operator_gtgt/index.md) - deserialize from stream
## Version history
- Added in version 3.0.0.
- Ignoring comments via `ignore_comments` added in version 3.9.0.
- Changed [runtime assertion](https://json.nlohmann.me/features/assertions/index.md) in case of `FILE*` null pointers to exception in version 3.12.0.
- Added `ignore_trailing_commas` in version 3.13.0.
- Extended container support (1) to include types with lvalue-only ADL `begin`/`end` (matching `std::begin`/`std::end` semantics) in version 3.13.0.
- Extended overload (2) to accept heterogeneous iterator+sentinel pairs (C++20 ranges support) in version 3.13.0.
Deprecation
Overload (2) replaces calls to `accept` with a pair of iterators as their first parameter which has been deprecated in version 3.8.0. This overload will be removed in version 4.0.0. Please replace all calls like `accept({ptr, ptr+len}, ...);` with `accept(ptr, ptr+len, ...);`.
You should be warned by your compiler with a `-Wdeprecated-declarations` warning if you are using a deprecated function.
-61
View File
@@ -1,61 +0,0 @@
# <small>nlohmann::basic_json::</small>array
```cpp
static basic_json array(initializer_list_t init = {});
```
Creates a JSON array value from a given initializer list. That is, given a list of values `a, b, c`, creates the JSON
value `#!json [a, b, c]`. If the initializer list is empty, the empty array `#!json []` is created.
## Parameters
`init` (in)
: initializer list with JSON values to create an array from (optional)
## Return value
JSON array value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the size of `init`.
## Notes
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor
([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are:
1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list
constructor would create an object, taking the first elements as keys
2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty
object
## Examples
??? example
The following code shows an example for the `array` function.
```cpp
--8<-- "examples/array.cpp"
```
Output:
```json
--8<-- "examples/array.output"
```
## See also
- [`basic_json(initializer_list_t)`](basic_json.md) - create a JSON value from an initializer list
- [`object`](object.md) - create a JSON object value from an initializer list
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-77
View File
@@ -1,77 +0,0 @@
# nlohmann::basic_json::array
```
static basic_json array(initializer_list_t init = {});
```
Creates a JSON array value from a given initializer list. That is, given a list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the initializer list is empty, the empty array `[]` is created.
## Parameters
`init` (in) : initializer list with JSON values to create an array from (optional)
## Return value
JSON array value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the size of `init`.
## Notes
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor ([`basic_json(initializer_list_t, bool, value_t)`](https://json.nlohmann.me/api/basic_json/basic_json/index.md)). These cases are:
1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list constructor would create an object, taking the first elements as keys
1. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty object
## Examples
Example
The following code shows an example for the `array` function.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON arrays
json j_no_init_list = json::array();
json j_empty_init_list = json::array({});
json j_nonempty_init_list = json::array({1, 2, 3, 4});
json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
// serialize the JSON arrays
std::cout << j_no_init_list << '\n';
std::cout << j_empty_init_list << '\n';
std::cout << j_nonempty_init_list << '\n';
std::cout << j_list_of_pairs << '\n';
}
```
Output:
```
[]
[]
[1,2,3,4]
[["one",1],["two",2]]
```
## See also
- [`basic_json(initializer_list_t)`](https://json.nlohmann.me/api/basic_json/basic_json/index.md) - create a JSON value from an initializer list
- [`object`](https://json.nlohmann.me/api/basic_json/object/index.md) - create a JSON object value from an initializer list
- [Creating JSON values](https://json.nlohmann.me/features/creating_values/index.md) - the article on creating JSON values
## Version history
- Added in version 1.0.0.
-68
View File
@@ -1,68 +0,0 @@
# <small>nlohmann::basic_json::</small>array_t
```cpp
using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
```
The type used to store JSON arrays.
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows:
> An array is an ordered sequence of zero or more values.
To store objects in C++, a type is defined by the template parameters explained below.
## Template parameters
`ArrayType`
: container type to store arrays (e.g., `std::vector` or `std::list`)
`AllocatorType`
: the allocator to use for objects (e.g., `std::allocator`)
## Notes
#### Default type
With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for
`array_t` is:
```cpp
std::vector<
basic_json, // value_type
std::allocator<basic_json> // allocator_type
>
```
#### Limits
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
> An implementation may set limits on the maximum depth of nesting.
In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be
introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the
[`max_size`](max_size.md) function of a JSON array.
#### Storage
Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type
`#!cpp array_t*` must be dereferenced.
## Examples
??? example
The following code shows that `array_t` is by default, a typedef to `#!cpp std::vector<nlohmann::json>`.
```cpp
--8<-- "examples/array_t.cpp"
```
Output:
```json
--8<-- "examples/array_t.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-73
View File
@@ -1,73 +0,0 @@
# nlohmann::basic_json::array_t
```
using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
```
The type used to store JSON arrays.
[RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows:
> An array is an ordered sequence of zero or more values.
To store objects in C++, a type is defined by the template parameters explained below.
## Template parameters
`ArrayType` : container type to store arrays (e.g., `std::vector` or `std::list`)
`AllocatorType` : the allocator to use for objects (e.g., `std::allocator`)
## Notes
#### Default type
With the default values for `ArrayType` (`std::vector`) and `AllocatorType` (`std::allocator`), the default value for `array_t` is:
```
std::vector<
basic_json, // value_type
std::allocator<basic_json> // allocator_type
>
```
#### Limits
[RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
> An implementation may set limits on the maximum depth of nesting.
In this class, the array's limit of nesting is not explicitly constrained. However, a maximum depth of nesting may be introduced by the compiler or runtime environment. A theoretical limit can be queried by calling the [`max_size`](https://json.nlohmann.me/api/basic_json/max_size/index.md) function of a JSON array.
#### Storage
Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of type `array_t*` must be dereferenced.
## Examples
Example
The following code shows that `array_t` is by default, a typedef to `std::vector<nlohmann::json>`.
```
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
}
```
Output:
```
true
```
## Version history
- Added in version 1.0.0.
-228
View File
@@ -1,228 +0,0 @@
# <small>nlohmann::basic_json::</small>at
```cpp
// (1)
reference at(size_type idx);
const_reference at(size_type idx) const;
// (2)
reference at(const typename object_t::key_type& key);
const_reference at(const typename object_t::key_type& key) const;
// (3)
template<typename KeyType>
reference at(KeyType&& key);
template<typename KeyType>
const_reference at(KeyType&& key) const;
// (4)
reference at(const json_pointer& ptr);
const_reference at(const json_pointer& ptr) const;
```
1. Returns a reference to the array element at specified location `idx`, with bounds checking.
2. Returns a reference to the object element with specified key `key`, with bounds checking.
3. See 2. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and
`#!cpp typename object_comparator_t::is_transparent` denotes a type.
4. Returns a reference to the element at specified JSON pointer `ptr`, with bounds checking.
## Template parameters
`KeyType`
: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with
[`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md).
This can also be a string view (C++17).
## Parameters
`idx` (in)
: index of the element to access
`key` (in)
: object key of the elements to access
`ptr` (in)
: JSON pointer to the desired element
## Return value
1. reference to the element at index `idx`
2. reference to the element at key `key`
3. reference to the element at key `key`
4. reference to the element pointed to by `ptr`
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. The function can throw the following exceptions:
- Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an array;
in this case, calling `at` with an index makes no sense. See the example below.
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if the index `idx` is out of
range of the array; that is, `idx >= size()`. See the example below.
2. The function can throw the following exceptions:
- Throws [`type_error.304`](../../home/exceptions.md#jsonexceptiontype_error304) if the JSON value is not an object;
in this case, calling `at` with a key makes no sense. See the example below.
- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the key `key` is not
stored in the object; that is, `find(key) == end()`. See the example below.
3. See 2.
4. The function can throw the following exceptions:
- Throws [`parse_error.106`](../../home/exceptions.md#jsonexceptionparse_error106) if an array index in the passed
JSON pointer `ptr` begins with '0'. See the example below.
- Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) if an array index in the passed
JSON pointer `ptr` is not a number. See the example below.
- Throws [`out_of_range.401`](../../home/exceptions.md#jsonexceptionout_of_range401) if an array index in the passed
JSON pointer `ptr` is out of range. See the example below.
- Throws [`out_of_range.402`](../../home/exceptions.md#jsonexceptionout_of_range402) if the array index '-' is used
in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the
index '-' is always invalid. See the example below.
- Throws [`out_of_range.403`](../../home/exceptions.md#jsonexceptionout_of_range403) if the JSON pointer describes a
key of an object which cannot be found. See the example below.
- Throws [`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) if the JSON pointer `ptr` can
not be resolved. See the example below.
- Throws [`out_of_range.410`](../../home/exceptions.md#jsonexceptionout_of_range410) if an array index in the passed
JSON pointer `ptr` exceeds the range of `size_type` (e.g., on 32-bit platforms).
## Complexity
1. Constant.
2. Logarithmic in the size of the container.
3. Logarithmic in the size of the container.
4. Logarithmic in the size of the container.
## Examples
??? example "Example: (1) access specified array element with bounds checking"
The example below shows how array elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at__size_type.cpp"
```
Output:
```json
--8<-- "examples/at__size_type.output"
```
??? example "Example: (1) access specified array element with bounds checking"
The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__size_type_const.cpp"
```
Output:
```json
--8<-- "examples/at__size_type_const.output"
```
??? example "Example: (2) access specified object element with bounds checking"
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/at__object_t_key_type.output"
```
??? example "Example: (2) access specified object element with bounds checking"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__object_t_key_type_const.cpp"
```
Output:
```json
--8<-- "examples/at__object_t_key_type_const.output"
```
??? example "Example: (3) access specified object element using string_view with bounds checking"
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/at__keytype.c++17.output"
```
??? example "Example: (3) access specified object element using string_view with bounds checking"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__keytype_const.c++17.cpp"
```
Output:
```json
--8<-- "examples/at__keytype_const.c++17.output"
```
??? example "Example: (4) access specified element via JSON Pointer"
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different
exceptions that can be thrown.
```cpp
--8<-- "examples/at__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/at__json_pointer.output"
```
??? example "Example: (4) access specified element via JSON Pointer"
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions
that can be thrown.
```cpp
--8<-- "examples/at__json_pointer_const.cpp"
```
Output:
```json
--8<-- "examples/at__json_pointer_const.output"
```
## See also
- documentation on [checked access](../../features/element_access/checked_access.md)
- [`operator[]`](operator%5B%5D.md) for unchecked access by reference
- [`value`](value.md) for access with default value
## Version history
1. Added in version 1.0.0.
2. Added in version 1.0.0.
3. Added in version 3.11.0.
4. Added in version 2.0.0.
File diff suppressed because one or more lines are too long
-668
View File
@@ -1,668 +0,0 @@
# nlohmann::basic_json::at
```
// (1)
reference at(size_type idx);
const_reference at(size_type idx) const;
// (2)
reference at(const typename object_t::key_type& key);
const_reference at(const typename object_t::key_type& key) const;
// (3)
template<typename KeyType>
reference at(KeyType&& key);
template<typename KeyType>
const_reference at(KeyType&& key) const;
// (4)
reference at(const json_pointer& ptr);
const_reference at(const json_pointer& ptr) const;
```
1. Returns a reference to the array element at specified location `idx`, with bounds checking.
1. Returns a reference to the object element with specified key `key`, with bounds checking.
1. See 2. This overload is only available if `KeyType` is comparable with `typename object_t::key_type` and `typename object_comparator_t::is_transparent` denotes a type.
1. Returns a reference to the element at specified JSON pointer `ptr`, with bounds checking.
## Template parameters
`KeyType` : A type for an object key other than [`json_pointer`](https://json.nlohmann.me/api/json_pointer/index.md) that is comparable with [`string_t`](https://json.nlohmann.me/api/basic_json/string_t/index.md) using [`object_comparator_t`](https://json.nlohmann.me/api/basic_json/object_comparator_t/index.md). This can also be a string view (C++17).
## Parameters
`idx` (in) : index of the element to access
`key` (in) : object key of the elements to access
`ptr` (in) : JSON pointer to the desired element
## Return value
1. reference to the element at index `idx`
1. reference to the element at key `key`
1. reference to the element at key `key`
1. reference to the element pointed to by `ptr`
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. The function can throw the following exceptions:
- Throws [`type_error.304`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error304) if the JSON value is not an array; in this case, calling `at` with an index makes no sense. See the example below.
- Throws [`out_of_range.401`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range401) if the index `idx` is out of range of the array; that is, `idx >= size()`. See the example below.
1. The function can throw the following exceptions:
- Throws [`type_error.304`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error304) if the JSON value is not an object; in this case, calling `at` with a key makes no sense. See the example below.
- Throws [`out_of_range.403`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range403) if the key `key` is not stored in the object; that is, `find(key) == end()`. See the example below.
1. See 2.
1. The function can throw the following exceptions:
- Throws [`parse_error.106`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error106) if an array index in the passed JSON pointer `ptr` begins with '0'. See the example below.
- Throws [`parse_error.109`](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error109) if an array index in the passed JSON pointer `ptr` is not a number. See the example below.
- Throws [`out_of_range.401`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range401) if an array index in the passed JSON pointer `ptr` is out of range. See the example below.
- Throws [`out_of_range.402`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range402) if the array index '-' is used in the passed JSON pointer `ptr`. As `at` provides checked access (and no elements are implicitly inserted), the index '-' is always invalid. See the example below.
- Throws [`out_of_range.403`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range403) if the JSON pointer describes a key of an object which cannot be found. See the example below.
- Throws [`out_of_range.404`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range404) if the JSON pointer `ptr` can not be resolved. See the example below.
- Throws [`out_of_range.410`](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range410) if an array index in the passed JSON pointer `ptr` exceeds the range of `size_type` (e.g., on 32-bit platforms).
## Complexity
1. Constant.
1. Logarithmic in the size of the container.
1. Logarithmic in the size of the container.
1. Logarithmic in the size of the container.
## Examples
Example: (1) access specified array element with bounds checking
The example below shows how array elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON array
json array = {"first", "2nd", "third", "fourth"};
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';
// change element at index 1 (second element) to "second"
array.at(1) = "second";
// output changed array
std::cout << array << '\n';
// exception type_error.304
try
{
// use at() on a non-array type
json str = "I am a string";
str.at(0) = "Another string";
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to write beyond the array limit
array.at(5) = "sixth";
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
"third"
["first","second","third","fourth"]
[json.exception.type_error.304] cannot use at() with string
[json.exception.out_of_range.401] array index 5 is out of range
```
Example: (1) access specified array element with bounds checking
The example below shows how array elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON array
const json array = {"first", "2nd", "third", "fourth"};
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';
// exception type_error.304
try
{
// use at() on a non-array type
const json str = "I am a string";
std::cout << str.at(0) << '\n';
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to read beyond the array limit
std::cout << array.at(5) << '\n';
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
"third"
[json.exception.type_error.304] cannot use at() with string
[json.exception.out_of_range.401] array index 5 is out of range
```
Example: (2) access specified object element with bounds checking
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON object
json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},
{"the ugly", "il brutto"}
};
// output element with key "the ugly"
std::cout << object.at("the ugly") << '\n';
// change element with key "the bad"
object.at("the bad") = "il cattivo";
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
// use at() on a non-object type
json str = "I am a string";
str.at("the good") = "Another string";
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to write at a nonexisting key
object.at("the fast") = "il rapido";
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
"il brutto"
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
[json.exception.type_error.304] cannot use at() with string
[json.exception.out_of_range.403] key 'the fast' not found
```
Example: (2) access specified object element with bounds checking
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON object
const json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},
{"the ugly", "il brutto"}
};
// output element with key "the ugly"
std::cout << object.at("the ugly") << '\n';
// exception type_error.304
try
{
// use at() on a non-object type
const json str = "I am a string";
std::cout << str.at("the good") << '\n';
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to read from a nonexisting key
std::cout << object.at("the fast") << '\n';
}
catch (const json::out_of_range)
{
std::cout << "out of range" << '\n';
}
}
```
Output:
```
"il brutto"
[json.exception.type_error.304] cannot use at() with string
out of range
```
Example: (3) access specified object element using string_view with bounds checking
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create JSON object
json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},
{"the ugly", "il brutto"}
};
// output element with key "the ugly" using string_view
std::cout << object.at("the ugly"sv) << '\n';
// change element with key "the bad" using string_view
object.at("the bad"sv) = "il cattivo";
// output changed array
std::cout << object << '\n';
// exception type_error.304
try
{
// use at() with string_view on a non-object type
json str = "I am a string";
str.at("the good"sv) = "Another string";
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to write at a nonexisting key using string_view
object.at("the fast"sv) = "il rapido";
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
"il brutto"
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
[json.exception.type_error.304] cannot use at() with string
[json.exception.out_of_range.403] key 'the fast' not found
```
Example: (3) access specified object element using string_view with bounds checking
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create JSON object
const json object =
{
{"the good", "il buono"},
{"the bad", "il cattivo"},
{"the ugly", "il brutto"}
};
// output element with key "the ugly" using string_view
std::cout << object.at("the ugly"sv) << '\n';
// exception type_error.304
try
{
// use at() with string_view on a non-object type
const json str = "I am a string";
std::cout << str.at("the good"sv) << '\n';
}
catch (const json::type_error& e)
{
std::cout << e.what() << '\n';
}
// exception out_of_range.401
try
{
// try to read from a nonexisting key using string_view
std::cout << object.at("the fast"sv) << '\n';
}
catch (const json::out_of_range& e)
{
std::cout << "out of range" << '\n';
}
}
```
Output:
```
"il brutto"
[json.exception.type_error.304] cannot use at() with string
out of range
```
Example: (4) access specified element via JSON Pointer
The example below shows how object elements can be read and written using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/number"
std::cout << j.at("/number"_json_pointer) << '\n';
// output element with JSON pointer "/string"
std::cout << j.at("/string"_json_pointer) << '\n';
// output element with JSON pointer "/array"
std::cout << j.at("/array"_json_pointer) << '\n';
// output element with JSON pointer "/array/1"
std::cout << j.at("/array/1"_json_pointer) << '\n';
// writing access
// change the string
j.at("/string"_json_pointer) = "bar";
// output the changed string
std::cout << j["string"] << '\n';
// change an array element
j.at("/array/1"_json_pointer) = 21;
// output the changed array
std::cout << j["array"] << '\n';
// out_of_range.106
try
{
// try to use an array index with leading '0'
json::reference ref = j.at("/array/01"_json_pointer);
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.109
try
{
// try to use an array index that is not a number
json::reference ref = j.at("/array/one"_json_pointer);
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.401
try
{
// try to use an invalid array index
json::reference ref = j.at("/array/4"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.402
try
{
// try to use the array index '-'
json::reference ref = j.at("/array/-"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.403
try
{
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.404
try
{
// try to use a JSON pointer that cannot be resolved
json::reference ref = j.at("/number/foo"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
1
"foo"
[1,2]
2
"bar"
[1,21]
[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'
[json.exception.parse_error.109] parse error: array index 'one' is not a number
[json.exception.out_of_range.401] array index 4 is out of range
[json.exception.out_of_range.402] array index '-' (2) is out of range
[json.exception.out_of_range.403] key 'foo' not found
[json.exception.out_of_range.404] unresolved reference token 'foo'
```
Example: (4) access specified element via JSON Pointer
The example below shows how object elements can be read using `at()`. It also demonstrates the different exceptions that can be thrown.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
const json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/number"
std::cout << j.at("/number"_json_pointer) << '\n';
// output element with JSON pointer "/string"
std::cout << j.at("/string"_json_pointer) << '\n';
// output element with JSON pointer "/array"
std::cout << j.at("/array"_json_pointer) << '\n';
// output element with JSON pointer "/array/1"
std::cout << j.at("/array/1"_json_pointer) << '\n';
// out_of_range.109
try
{
// try to use an array index that is not a number
json::const_reference ref = j.at("/array/one"_json_pointer);
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.401
try
{
// try to use an invalid array index
json::const_reference ref = j.at("/array/4"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.402
try
{
// try to use the array index '-'
json::const_reference ref = j.at("/array/-"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.403
try
{
// try to use a JSON pointer to a nonexistent object key
json::const_reference ref = j.at("/foo"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
// out_of_range.404
try
{
// try to use a JSON pointer that cannot be resolved
json::const_reference ref = j.at("/number/foo"_json_pointer);
}
catch (const json::out_of_range& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
1
"foo"
[1,2]
2
[json.exception.parse_error.109] parse error: array index 'one' is not a number
[json.exception.out_of_range.401] array index 4 is out of range
[json.exception.out_of_range.402] array index '-' (2) is out of range
[json.exception.out_of_range.403] key 'foo' not found
[json.exception.out_of_range.404] unresolved reference token 'foo'
```
## See also
- documentation on [checked access](https://json.nlohmann.me/features/element_access/checked_access/index.md)
- [`operator[]`](https://json.nlohmann.me/api/basic_json/operator%5B%5D/index.md) for unchecked access by reference
- [`value`](https://json.nlohmann.me/api/basic_json/value/index.md) for access with default value
## Version history
1. Added in version 1.0.0.
1. Added in version 1.0.0.
1. Added in version 3.11.0.
1. Added in version 2.0.0.
-65
View File
@@ -1,65 +0,0 @@
# <small>nlohmann::basic_json::</small>back
```cpp
reference back();
const_reference back() const;
```
Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is
equivalent to
```cpp
auto tmp = c.end();
--tmp;
return *tmp;
```
## Return value
In the case of a structured type (array or object), a reference to the last element is returned. In the case of number,
string, boolean, or binary values, a reference to the value is returned.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Exceptions
If the JSON value is `#!json null`, exception
[`invalid_iterator.214`](../../home/exceptions.md#jsonexceptioninvalid_iterator214) is thrown.
## Complexity
Constant.
## Notes
!!! info "Precondition"
The array or object must not be empty. Calling `back` on an empty array or object yields undefined behavior.
## Examples
??? example
The following code shows an example for `back()`.
```cpp
--8<-- "examples/back.cpp"
```
Output:
```json
--8<-- "examples/back.output"
```
## See also
- [front](front.md) to access the first element
## Version history
- Added in version 1.0.0.
- Adjusted code to return reference to binary values in version 3.8.0.
File diff suppressed because one or more lines are too long
-105
View File
@@ -1,105 +0,0 @@
# nlohmann::basic_json::back
```
reference back();
const_reference back() const;
```
Returns a reference to the last element in the container. For a JSON container `c`, the expression `c.back()` is equivalent to
```
auto tmp = c.end();
--tmp;
return *tmp;
```
## Return value
In the case of a structured type (array or object), a reference to the last element is returned. In the case of number, string, boolean, or binary values, a reference to the value is returned.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Exceptions
If the JSON value is `null`, exception [`invalid_iterator.214`](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator214) is thrown.
## Complexity
Constant.
## Notes
Precondition
The array or object must not be empty. Calling `back` on an empty array or object yields undefined behavior.
## Examples
Example
The following code shows an example for `back()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_boolean = true;
json j_number_integer = 17;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_object_empty(json::value_t::object);
json j_array = {1, 2, 4, 8, 16};
json j_array_empty(json::value_t::array);
json j_string = "Hello, world";
// call back()
std::cout << j_boolean.back() << '\n';
std::cout << j_number_integer.back() << '\n';
std::cout << j_number_float.back() << '\n';
std::cout << j_object.back() << '\n';
//std::cout << j_object_empty.back() << '\n'; // undefined behavior
std::cout << j_array.back() << '\n';
//std::cout << j_array_empty.back() << '\n'; // undefined behavior
std::cout << j_string.back() << '\n';
// back() called on a null value
try
{
json j_null;
j_null.back();
}
catch (const json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
true
17
23.42
2
16
"Hello, world"
[json.exception.invalid_iterator.214] cannot get value
```
## See also
- [front](https://json.nlohmann.me/api/basic_json/front/index.md) to access the first element
## Version history
- Added in version 1.0.0.
- Adjusted code to return reference to binary values in version 3.8.0.
-428
View File
@@ -1,428 +0,0 @@
# <small>nlohmann::basic_json::</small>basic_json
```cpp
// (1)
basic_json(const value_t v);
// (2)
basic_json(std::nullptr_t = nullptr) noexcept;
// (3)
template<typename CompatibleType>
basic_json(CompatibleType&& val) noexcept(noexcept(
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
std::forward<CompatibleType>(val))));
// (4)
template<typename BasicJsonType>
basic_json(const BasicJsonType& val);
// (5)
basic_json(initializer_list_t init,
bool type_deduction = true,
value_t manual_type = value_t::array);
// (6)
basic_json(size_type cnt, const basic_json& val);
// (7)
basic_json(iterator first, iterator last);
basic_json(const_iterator first, const_iterator last);
// (8)
basic_json(const basic_json& other);
// (9)
basic_json(basic_json&& other) noexcept;
```
1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends
on the type:
| Value type | initial value |
|------------|----------------|
| null | `#!json null` |
| boolean | `#!json false` |
| string | `#!json ""` |
| number | `#!json 0` |
| object | `#!json {}` |
| array | `#!json []` |
| binary | empty array |
The postcondition of this constructor can be restored by calling [`clear()`](clear.md).
2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`)
or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to
choose the right constructor.
3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method
exists. The constructor forwards the parameter `val` to that method (to `json_serializer<U>::to_json` method with
`U = uncvref_t<CompatibleType>`, to be exact).
Template type `CompatibleType` includes, but is not limited to, the following types:
- **arrays**: [`array_t`](array_t.md) and all kinds of compatible containers such as `std::vector`, `std::deque`,
`std::list`, `std::forward_list`, `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, `std::multiset`,
and `std::unordered_multiset` with a `value_type` from which a `basic_json` value can be constructed.
- **objects**: [`object_t`](object_t.md) and all kinds of compatible associative containers such as `std::map`,
`std::unordered_map`, `std::multimap`, and `std::unordered_multimap` with a `key_type` compatible to `string_t`
and a `value_type` from which a `basic_json` value can be constructed.
- **strings**: `string_t`, string literals, and all compatible string containers can be used.
- **numbers**: [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md),
[`number_float_t`](number_float_t.md), and all convertible number types such as `int`, `size_t`, `int64_t`, `float`
or `double` can be used.
- **boolean**: `boolean_t` / `bool` can be used.
- **binary**: `binary_t` / `std::vector<uint8_t>` may be used; unfortunately because string literals cannot be
distinguished from binary character arrays by the C++ type system, all types compatible with `const char*` will be
directed to the string constructor instead. This is both for backwards compatibility and due to the fact that a
binary type is not a standard JSON type.
See the examples below.
4. This is a constructor for existing `basic_json` types. It does not hijack copy/move constructors, since the parameter
has different template arguments than the current ones.
The constructor tries to convert the internal `m_value` of the parameter. Each member value (object, array, string,
etc.) is serialized via the corresponding `to_json()` overload. For objects and strings, the conversion requires
that the *target* `basic_json` type's `object_t::key_type` (or `string_t`) be directly constructible from the
*source* type's corresponding member type via `is_constructible`. If this requirement is not met, the conversion
does not fail to compile; instead, it silently falls back to the array-conversion path, which represents objects
as arrays of `[key, value]` pairs and strings as arrays of character codes. This is a known limitation tracked in
[issue #3425](https://github.com/nlohmann/json/issues/3425).
5. Creates a JSON value of type array or object from the passed initializer list `init`. In case `type_deduction` is
`#!cpp true` (default), the type of the JSON value to be created is deducted from the initializer list `init`
according to the following rules:
1. If the list is empty, an empty JSON object value `{}` is created.
2. If the list consists of pairs whose first element is a string, a JSON object value is created where the first
elements of the pairs are treated as keys and the second elements are as values.
3. In all other cases, an array is created.
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
2. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be
of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an
object.
3. In all other cases, the initializer list could not be interpreted as a JSON object type, so interpreting it as a
JSON array type is safe.
With the rules described above, the following JSON values cannot be expressed by an initializer list:
- the empty array (`#!json []`): use `array(initializer_list_t)` with an empty initializer list in this case
- arrays whose elements satisfy rule 2: use `array(initializer_list_t)` with the same initializer list in this case
Function [`array()`](array.md) and [`object()`](object.md) force array and object creation from initializer lists,
respectively.
!!! warning "Brace initialization yields arrays"
Because this constructor takes an `initializer_list_t`, brace-initializing a `json`/`ordered_json` from
another `json` value wraps it in a single-element array rather than copying it:
```cpp
json j1 = "hello";
json j2{j1}; // [!] j2 is ["hello"], NOT a copy of j1
json j3(j1); // j3 is "hello" -- parentheses copy as expected
```
See the FAQ entry on [brace initialization](../../home/faq.md#brace-initialization-yields-arrays) for the
full explanation, an opt-in macro to change this behavior, and how to explicitly create a single-element
array (`json::array({value})`) if that is what you want.
6. Constructs a JSON array value by creating `cnt` copies of a passed value. In case `cnt` is `0`, an empty array is
created.
7. Constructs the JSON value with the contents of the range `[first, last)`. The semantics depend on the different
types a JSON value can have:
- In case of a `#!json null` type, [invalid_iterator.206](../../home/exceptions.md#jsonexceptioninvalid_iterator206)
is thrown.
- In case of other primitive types (number, boolean, or string), `first` must be `begin()` and `last` must be
`end()`. In this case, the value is copied. Otherwise,
[`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) is thrown.
- In case of structured types (array, object), the constructor behaves as similar versions for `std::vector` or
`std::map`; that is, a JSON array or object is constructed from the values in the range.
8. Creates a copy of a given JSON value.
9. Move constructor. Constructs a JSON value with the contents of the given value `other` using move semantics. It
"steals" the resources from `other` and leaves it as JSON `#!json null` value.
## Template parameters
`CompatibleType`
: a type such that:
- `CompatibleType` is not derived from `std::istream`,
- `CompatibleType` is not `basic_json` (to avoid hijacking copy/move constructors),
- `CompatibleType` is not a different `basic_json` type (i.e. with different template arguments)
- `CompatibleType` is not a `basic_json` nested type (e.g., `json_pointer`, `iterator`, etc.)
- `json_serializer<U>` (with `U = uncvref_t<CompatibleType>`) has a `to_json(basic_json_t&, CompatibleType&&)`
method
`BasicJsonType`:
: a type such that:
- `BasicJsonType` is a `basic_json` type.
- `BasicJsonType` has different template arguments than `basic_json_t`.
**Note:** For cross-`basic_json` conversions to produce correct results, the target `basic_json`'s
`object_t::key_type` and `string_t` must be directly constructible from the source `basic_json`'s
corresponding types. See the description of overload (4) above for details on what happens when
this requirement is not met.
`U`:
: `uncvref_t<CompatibleType>`
## Parameters
`v` (in)
: the type of the value to create
`val` (in)
: the value to be forwarded to the respective constructor
`init` (in)
: initializer list with JSON values
`type_deduction` (in)
: internal parameter; when set to `#!cpp true`, the type of the JSON value is deducted from the initializer list
`init`; when set to `#!cpp false`, the type provided via `manual_type` is forced. This mode is used by the functions
`array(initializer_list_t)` and `object(initializer_list_t)`.
`manual_type` (in)
: internal parameter; when `type_deduction` is set to `#!cpp false`, the created JSON value will use the provided type
(only `value_t::array` and `value_t::object` are valid); when `type_deduction` is set to `#!cpp true`, this
parameter has no effect
`cnt` (in)
: the number of JSON copies of `val` to create
`first` (in)
: the beginning of the range to copy from (included)
`last` (in)
: the end of the range to copy from (excluded)
`other` (in)
: the JSON value to copy/move
## Exception safety
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
2. No-throw guarantee: this constructor never throws exceptions.
3. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no
`to_json()` function was provided), a strong guarantee holds: if an exception is thrown, there are no changes to any
JSON value.
4. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no
`to_json()` function was provided), a strong guarantee holds: if an exception is thrown, there are no changes to any
JSON value.
5. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
6. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
7. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
8. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
9. No-throw guarantee: this constructor never throws exceptions.
## Exceptions
1. (none)
2. The function does not throw exceptions.
3. (none)
4. (none)
5. The function can throw the following exceptions:
- Throws [`type_error.301`](../../home/exceptions.md#jsonexceptiontype_error301) if `type_deduction` is
`#!cpp false`, `manual_type` is `value_t::object`, but `init` contains an element which is not a pair whose first
element is a string. In this case, the constructor could not create an object. If `type_deduction` would have been
`#!cpp true`, an array would have been created. See `object(initializer_list_t)` for an example.
6. (none)
7. The function can throw the following exceptions:
- Throws [`invalid_iterator.201`](../../home/exceptions.md#jsonexceptioninvalid_iterator201) if iterators `first`
and `last` are not compatible (i.e., do not belong to the same JSON value). In this case, the range
`[first, last)` is undefined.
- Throws [`invalid_iterator.204`](../../home/exceptions.md#jsonexceptioninvalid_iterator204) if iterators `first`
and `last` belong to a primitive type (number, boolean, or string), but `first` does not point to the first
element anymore. In this case, the range `[first, last)` is undefined. See the example code below.
- Throws [`invalid_iterator.206`](../../home/exceptions.md#jsonexceptioninvalid_iterator206) if iterators `first`
and `last` belong to a `#!json null` value. In this case, the range `[first, last)` is undefined.
8. (none)
9. The function does not throw exceptions.
## Complexity
1. Constant.
2. Constant.
3. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()`
method.
4. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()`
method.
5. Linear in the size of the initializer list `init`.
6. Linear in `cnt`.
7. Linear in distance between `first` and `last`.
8. Linear in the size of `other`.
9. Constant.
## Notes
- Overload 5:
!!! note "Empty initializer list"
When used without parentheses around an empty initializer list, `basic_json()` is called instead of this
function, yielding the JSON `#!json null` value.
- Overload 7:
!!! info "Preconditions"
- Iterators `first` and `last` must be initialized. **This precondition is enforced with a
[runtime assertion](../../features/assertions.md).
- Range `[first, last)` is valid. Usually, this precondition cannot be checked efficiently. Only certain edge
cases are detected; see the description of the exceptions above. A violation of this precondition yields
undefined behavior.
!!! danger "Runtime assertion"
A precondition is enforced with a [runtime assertion](../../features/assertions.md).
- Overload 8:
!!! info "Postcondition"
`#!cpp *this == other`
- Overload 9:
!!! info "Postconditions"
- `#!cpp `*this` has the same value as `other` before the call.
- `other` is a JSON `#!json null` value
## Examples
??? example "Example: (1) create an empty value with a given type"
The following code shows the constructor for different `value_t` values.
```cpp
--8<-- "examples/basic_json__value_t.cpp"
```
Output:
```json
--8<-- "examples/basic_json__value_t.output"
```
??? example "Example: (2) create a `#!json null` object"
The following code shows the constructor with and without a null pointer parameter.
```cpp
--8<-- "examples/basic_json__nullptr_t.cpp"
```
Output:
```json
--8<-- "examples/basic_json__nullptr_t.output"
```
??? example "Example: (3) create a JSON value from compatible types"
The following code shows the constructor with several compatible types.
```cpp
--8<-- "examples/basic_json__CompatibleType.cpp"
```
Output:
```json
--8<-- "examples/basic_json__CompatibleType.output"
```
Note the output is platform-dependent.
??? example "Example: (5) create a container (array or object) from an initializer list"
The example below shows how JSON values are created from initializer lists.
```cpp
--8<-- "examples/basic_json__list_init_t.cpp"
```
Output:
```json
--8<-- "examples/basic_json__list_init_t.output"
```
??? example "Example: (6) construct an array with count copies of a given value"
The following code shows examples for creating arrays with several copies of a given value.
```cpp
--8<-- "examples/basic_json__size_type_basic_json.cpp"
```
Output:
```json
--8<-- "examples/basic_json__size_type_basic_json.output"
```
??? example "Example: (7) construct a JSON container given an iterator range"
The example below shows several ways to create JSON values by specifying a subrange with iterators.
```cpp
--8<-- "examples/basic_json__InputIt_InputIt.cpp"
```
Output:
```json
--8<-- "examples/basic_json__InputIt_InputIt.output"
```
??? example "Example: (8) copy constructor"
The following code shows an example for the copy constructor.
```cpp
--8<-- "examples/basic_json__basic_json.cpp"
```
Output:
```json
--8<-- "examples/basic_json__basic_json.output"
```
??? example "Example: (9) move constructor"
The code below shows the move constructor explicitly called via `std::move`.
```cpp
--8<-- "examples/basic_json__moveconstructor.cpp"
```
Output:
```json
--8<-- "examples/basic_json__moveconstructor.output"
```
## Version history
1. Since version 1.0.0.
2. Since version 1.0.0.
3. Since version 2.1.0.
4. Since version 3.2.0.
5. Since version 1.0.0.
6. Since version 1.0.0.
7. Since version 1.0.0.
8. Since version 1.0.0.
9. Since version 1.0.0.
File diff suppressed because one or more lines are too long
-768
View File
@@ -1,768 +0,0 @@
# nlohmann::basic_json::basic_json
```
// (1)
basic_json(const value_t v);
// (2)
basic_json(std::nullptr_t = nullptr) noexcept;
// (3)
template<typename CompatibleType>
basic_json(CompatibleType&& val) noexcept(noexcept(
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
std::forward<CompatibleType>(val))));
// (4)
template<typename BasicJsonType>
basic_json(const BasicJsonType& val);
// (5)
basic_json(initializer_list_t init,
bool type_deduction = true,
value_t manual_type = value_t::array);
// (6)
basic_json(size_type cnt, const basic_json& val);
// (7)
basic_json(iterator first, iterator last);
basic_json(const_iterator first, const_iterator last);
// (8)
basic_json(const basic_json& other);
// (9)
basic_json(basic_json&& other) noexcept;
```
1. Create an empty JSON value with a given type. The value will be default initialized with an empty value which depends on the type:
| Value type | initial value |
| ---------- | ------------- |
| null | `null` |
| boolean | `false` |
| string | `""` |
| number | `0` |
| object | `{}` |
| array | `[]` |
| binary | empty array |
The postcondition of this constructor can be restored by calling [`clear()`](https://json.nlohmann.me/api/basic_json/clear/index.md).
1. Create a `null` JSON value. It either takes a null pointer as parameter (explicitly creating `null`) or no parameter (implicitly creating `null`). The passed null pointer itself is not read -- it is only used to choose the right constructor.
1. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method exists. The constructor forwards the parameter `val` to that method (to `json_serializer<U>::to_json` method with `U = uncvref_t<CompatibleType>`, to be exact).
Template type `CompatibleType` includes, but is not limited to, the following types:
- **arrays**: [`array_t`](https://json.nlohmann.me/api/basic_json/array_t/index.md) and all kinds of compatible containers such as `std::vector`, `std::deque`, `std::list`, `std::forward_list`, `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, `std::multiset`, and `std::unordered_multiset` with a `value_type` from which a `basic_json` value can be constructed.
- **objects**: [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md) and all kinds of compatible associative containers such as `std::map`, `std::unordered_map`, `std::multimap`, and `std::unordered_multimap` with a `key_type` compatible to `string_t` and a `value_type` from which a `basic_json` value can be constructed.
- **strings**: `string_t`, string literals, and all compatible string containers can be used.
- **numbers**: [`number_integer_t`](https://json.nlohmann.me/api/basic_json/number_integer_t/index.md), [`number_unsigned_t`](https://json.nlohmann.me/api/basic_json/number_unsigned_t/index.md), [`number_float_t`](https://json.nlohmann.me/api/basic_json/number_float_t/index.md), and all convertible number types such as `int`, `size_t`, `int64_t`, `float` or `double` can be used.
- **boolean**: `boolean_t` / `bool` can be used.
- **binary**: `binary_t` / `std::vector<uint8_t>` may be used; unfortunately because string literals cannot be distinguished from binary character arrays by the C++ type system, all types compatible with `const char*` will be directed to the string constructor instead. This is both for backwards compatibility and due to the fact that a binary type is not a standard JSON type.
See the examples below.
1. This is a constructor for existing `basic_json` types. It does not hijack copy/move constructors, since the parameter has different template arguments than the current ones.
The constructor tries to convert the internal `m_value` of the parameter. Each member value (object, array, string, etc.) is serialized via the corresponding `to_json()` overload. For objects and strings, the conversion requires that the *target* `basic_json` type's `object_t::key_type` (or `string_t`) be directly constructible from the *source* type's corresponding member type via `is_constructible`. If this requirement is not met, the conversion does not fail to compile; instead, it silently falls back to the array-conversion path, which represents objects as arrays of `[key, value]` pairs and strings as arrays of character codes. This is a known limitation tracked in [issue #3425](https://github.com/nlohmann/json/issues/3425).
1. Creates a JSON value of type array or object from the passed initializer list `init`. In case `type_deduction` is `true` (default), the type of the JSON value to be created is deducted from the initializer list `init` according to the following rules:
1. If the list is empty, an empty JSON object value `{}` is created.
1. If the list consists of pairs whose first element is a string, a JSON object value is created where the first elements of the pairs are treated as keys and the second elements are as values.
1. In all other cases, an array is created.
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
1. The empty initializer list is written as `{}` which is exactly an empty JSON object.
1. C++ has no way of describing mapped types other than to list a list of pairs. As JSON requires that keys must be of type string, rule 2 is the weakest constraint one can pose on initializer lists to interpret them as an object.
1. In all other cases, the initializer list could not be interpreted as a JSON object type, so interpreting it as a JSON array type is safe.
With the rules described above, the following JSON values cannot be expressed by an initializer list:
- the empty array (`[]`): use `array(initializer_list_t)` with an empty initializer list in this case
- arrays whose elements satisfy rule 2: use `array(initializer_list_t)` with the same initializer list in this case
Function [`array()`](https://json.nlohmann.me/api/basic_json/array/index.md) and [`object()`](https://json.nlohmann.me/api/basic_json/object/index.md) force array and object creation from initializer lists, respectively.
Brace initialization yields arrays
Because this constructor takes an `initializer_list_t`, brace-initializing a `json`/`ordered_json` from another `json` value wraps it in a single-element array rather than copying it:
```
json j1 = "hello";
json j2{j1}; // [!] j2 is ["hello"], NOT a copy of j1
json j3(j1); // j3 is "hello" -- parentheses copy as expected
```
See the FAQ entry on [brace initialization](https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays) for the full explanation, an opt-in macro to change this behavior, and how to explicitly create a single-element array (`json::array({value})`) if that is what you want.
1. Constructs a JSON array value by creating `cnt` copies of a passed value. In case `cnt` is `0`, an empty array is created.
1. Constructs the JSON value with the contents of the range `[first, last)`. The semantics depend on the different types a JSON value can have:
- In case of a `null` type, [invalid_iterator.206](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator206) is thrown.
- In case of other primitive types (number, boolean, or string), `first` must be `begin()` and `last` must be `end()`. In this case, the value is copied. Otherwise, [`invalid_iterator.204`](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator204) is thrown.
- In case of structured types (array, object), the constructor behaves as similar versions for `std::vector` or `std::map`; that is, a JSON array or object is constructed from the values in the range.
1. Creates a copy of a given JSON value.
1. Move constructor. Constructs a JSON value with the contents of the given value `other` using move semantics. It "steals" the resources from `other` and leaves it as JSON `null` value.
## Template parameters
`CompatibleType` : a type such that:
```
- `CompatibleType` is not derived from `std::istream`,
- `CompatibleType` is not `basic_json` (to avoid hijacking copy/move constructors),
- `CompatibleType` is not a different `basic_json` type (i.e. with different template arguments)
- `CompatibleType` is not a `basic_json` nested type (e.g., `json_pointer`, `iterator`, etc.)
- `json_serializer<U>` (with `U = uncvref_t<CompatibleType>`) has a `to_json(basic_json_t&, CompatibleType&&)`
method
```
`BasicJsonType`: : a type such that:
```
- `BasicJsonType` is a `basic_json` type.
- `BasicJsonType` has different template arguments than `basic_json_t`.
**Note:** For cross-`basic_json` conversions to produce correct results, the target `basic_json`'s
`object_t::key_type` and `string_t` must be directly constructible from the source `basic_json`'s
corresponding types. See the description of overload (4) above for details on what happens when
this requirement is not met.
```
`U`: : `uncvref_t<CompatibleType>`
## Parameters
`v` (in) : the type of the value to create
`val` (in) : the value to be forwarded to the respective constructor
`init` (in) : initializer list with JSON values
`type_deduction` (in) : internal parameter; when set to `true`, the type of the JSON value is deducted from the initializer list `init`; when set to `false`, the type provided via `manual_type` is forced. This mode is used by the functions `array(initializer_list_t)` and `object(initializer_list_t)`.
`manual_type` (in) : internal parameter; when `type_deduction` is set to `false`, the created JSON value will use the provided type (only `value_t::array` and `value_t::object` are valid); when `type_deduction` is set to `true`, this parameter has no effect
`cnt` (in) : the number of JSON copies of `val` to create
`first` (in) : the beginning of the range to copy from (included)
`last` (in) : the end of the range to copy from (excluded)
`other` (in) : the JSON value to copy/move
## Exception safety
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
1. No-throw guarantee: this constructor never throws exceptions.
1. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no `to_json()` function was provided), a strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
1. Depends on the called constructor. For types directly supported by the library (i.e., all types for which no `to_json()` function was provided), a strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
1. Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
1. No-throw guarantee: this constructor never throws exceptions.
## Exceptions
1. (none)
1. The function does not throw exceptions.
1. (none)
1. (none)
1. The function can throw the following exceptions:
- Throws [`type_error.301`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error301) if `type_deduction` is `false`, `manual_type` is `value_t::object`, but `init` contains an element which is not a pair whose first element is a string. In this case, the constructor could not create an object. If `type_deduction` would have been `true`, an array would have been created. See `object(initializer_list_t)` for an example.
1. (none)
1. The function can throw the following exceptions:
- Throws [`invalid_iterator.201`](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator201) if iterators `first` and `last` are not compatible (i.e., do not belong to the same JSON value). In this case, the range `[first, last)` is undefined.
- Throws [`invalid_iterator.204`](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator204) if iterators `first` and `last` belong to a primitive type (number, boolean, or string), but `first` does not point to the first element anymore. In this case, the range `[first, last)` is undefined. See the example code below.
- Throws [`invalid_iterator.206`](https://json.nlohmann.me/home/exceptions/#jsonexceptioninvalid_iterator206) if iterators `first` and `last` belong to a `null` value. In this case, the range `[first, last)` is undefined.
1. (none)
1. The function does not throw exceptions.
## Complexity
1. Constant.
1. Constant.
1. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()` method.
1. Usually linear in the size of the passed `val`, also depending on the implementation of the called `to_json()` method.
1. Linear in the size of the initializer list `init`.
1. Linear in `cnt`.
1. Linear in distance between `first` and `last`.
1. Linear in the size of `other`.
1. Constant.
## Notes
- Overload 5:
Empty initializer list
When used without parentheses around an empty initializer list, `basic_json()` is called instead of this function, yielding the JSON `null` value.
- Overload 7:
Preconditions
- Iterators `first` and `last` must be initialized. \*\*This precondition is enforced with a [runtime assertion](https://json.nlohmann.me/features/assertions/index.md).
- Range `[first, last)` is valid. Usually, this precondition cannot be checked efficiently. Only certain edge cases are detected; see the description of the exceptions above. A violation of this precondition yields undefined behavior.
Runtime assertion
A precondition is enforced with a [runtime assertion](https://json.nlohmann.me/features/assertions/index.md).
- Overload 8:
Postcondition
`*this == other`
- Overload 9:
Postconditions
- `` `*this `` has the same value as `other` before the call.
- `other` is a JSON `null` value
## Examples
Example: (1) create an empty value with a given type
The following code shows the constructor for different `value_t` values.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create the different JSON values with default values
json j_null(json::value_t::null);
json j_boolean(json::value_t::boolean);
json j_number_integer(json::value_t::number_integer);
json j_number_float(json::value_t::number_float);
json j_object(json::value_t::object);
json j_array(json::value_t::array);
json j_string(json::value_t::string);
// serialize the JSON values
std::cout << j_null << '\n';
std::cout << j_boolean << '\n';
std::cout << j_number_integer << '\n';
std::cout << j_number_float << '\n';
std::cout << j_object << '\n';
std::cout << j_array << '\n';
std::cout << j_string << '\n';
}
```
Output:
```
null
false
0
0.0
{}
[]
""
```
Example: (2) create a `null` object
The following code shows the constructor with and without a null pointer parameter.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// implicitly create a JSON null value
json j1;
// explicitly create a JSON null value
json j2(nullptr);
// serialize the JSON null value
std::cout << j1 << '\n' << j2 << '\n';
}
```
Output:
```
null
null
```
Example: (3) create a JSON value from compatible types
The following code shows the constructor with several compatible types.
```
#include <iostream>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// ============
// object types
// ============
// create an object from an object_t value
json::object_t object_value = { {"one", 1}, {"two", 2} };
json j_object_t(object_value);
// create an object from std::map
std::map<std::string, int> c_map
{
{"one", 1}, {"two", 2}, {"three", 3}
};
json j_map(c_map);
// create an object from std::unordered_map
std::unordered_map<const char*, double> c_umap
{
{"one", 1.2}, {"two", 2.3}, {"three", 3.4}
};
json j_umap(c_umap);
// create an object from std::multimap
std::multimap<std::string, bool> c_mmap
{
{"one", true}, {"two", true}, {"three", false}, {"three", true}
};
json j_mmap(c_mmap); // only one entry for key "three" is used
// create an object from std::unordered_multimap
std::unordered_multimap<std::string, bool> c_ummap
{
{"one", true}, {"two", true}, {"three", false}, {"three", true}
};
json j_ummap(c_ummap); // only one entry for key "three" is used
// serialize the JSON objects
std::cout << j_object_t << '\n';
std::cout << j_map << '\n';
std::cout << j_umap << '\n';
std::cout << j_mmap << '\n';
std::cout << j_ummap << "\n\n";
// ===========
// array types
// ===========
// create an array from an array_t value
json::array_t array_value = {"one", "two", 3, 4.5, false};
json j_array_t(array_value);
// create an array from std::vector
std::vector<int> c_vector {1, 2, 3, 4};
json j_vec(c_vector);
// create an array from std::valarray
std::valarray<short> c_valarray {10, 9, 8, 7};
json j_valarray(c_valarray);
// create an array from std::deque
std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
json j_deque(c_deque);
// create an array from std::list
std::list<bool> c_list {true, true, false, true};
json j_list(c_list);
// create an array from std::forward_list
std::forward_list<std::int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
json j_flist(c_flist);
// create an array from std::array
std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
json j_array(c_array);
// create an array from std::set
std::set<std::string> c_set {"one", "two", "three", "four", "one"};
json j_set(c_set); // only one entry for "one" is used
// create an array from std::unordered_set
std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
json j_uset(c_uset); // only one entry for "one" is used
// create an array from std::multiset
std::multiset<std::string> c_mset {"one", "two", "one", "four"};
json j_mset(c_mset); // both entries for "one" are used
// create an array from std::unordered_multiset
std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
json j_umset(c_umset); // both entries for "one" are used
// serialize the JSON arrays
std::cout << j_array_t << '\n';
std::cout << j_vec << '\n';
std::cout << j_valarray << '\n';
std::cout << j_deque << '\n';
std::cout << j_list << '\n';
std::cout << j_flist << '\n';
std::cout << j_array << '\n';
std::cout << j_set << '\n';
std::cout << j_uset << '\n';
std::cout << j_mset << '\n';
std::cout << j_umset << "\n\n";
// ============
// string types
// ============
// create string from a string_t value
json::string_t string_value = "The quick brown fox jumps over the lazy dog.";
json j_string_t(string_value);
// create a JSON string directly from a string literal
json j_string_literal("The quick brown fox jumps over the lazy dog.");
// create string from std::string
std::string s_stdstring = "The quick brown fox jumps over the lazy dog.";
json j_stdstring(s_stdstring);
// serialize the JSON strings
std::cout << j_string_t << '\n';
std::cout << j_string_literal << '\n';
std::cout << j_stdstring << "\n\n";
// ============
// number types
// ============
// create a JSON number from number_integer_t
json::number_integer_t value_integer_t = -42;
json j_integer_t(value_integer_t);
// create a JSON number from number_unsigned_t
json::number_integer_t value_unsigned_t = 17;
json j_unsigned_t(value_unsigned_t);
// create a JSON number from an anonymous enum
enum { enum_value = 17 };
json j_enum(enum_value);
// create values of different integer types
short n_short = 42;
int n_int = -23;
long n_long = 1024;
int_least32_t n_int_least32_t = -17;
uint8_t n_uint8_t = 8;
// create (integer) JSON numbers
json j_short(n_short);
json j_int(n_int);
json j_long(n_long);
json j_int_least32_t(n_int_least32_t);
json j_uint8_t(n_uint8_t);
// create values of different floating-point types
json::number_float_t v_ok = 3.141592653589793;
json::number_float_t v_nan = NAN;
json::number_float_t v_infinity = INFINITY;
// create values of different floating-point types
float n_float = 42.23;
float n_float_nan = 1.0f / 0.0f;
double n_double = 23.42;
// create (floating point) JSON numbers
json j_ok(v_ok);
json j_nan(v_nan);
json j_infinity(v_infinity);
json j_float(n_float);
json j_float_nan(n_float_nan);
json j_double(n_double);
// serialize the JSON numbers
std::cout << j_integer_t << '\n';
std::cout << j_unsigned_t << '\n';
std::cout << j_enum << '\n';
std::cout << j_short << '\n';
std::cout << j_int << '\n';
std::cout << j_long << '\n';
std::cout << j_int_least32_t << '\n';
std::cout << j_uint8_t << '\n';
std::cout << j_ok << '\n';
std::cout << j_nan << '\n';
std::cout << j_infinity << '\n';
std::cout << j_float << '\n';
std::cout << j_float_nan << '\n';
std::cout << j_double << "\n\n";
// =============
// boolean types
// =============
// create boolean values
json j_truth = true;
json j_falsity = false;
// serialize the JSON booleans
std::cout << j_truth << '\n';
std::cout << j_falsity << '\n';
}
```
Output:
```
{"one":1,"two":2}
{"one":1,"three":3,"two":2}
{"one":1.2,"three":3.4,"two":2.3}
{"one":true,"three":false,"two":true}
{"one":true,"three":false,"two":true}
["one","two",3,4.5,false]
[1,2,3,4]
[10,9,8,7]
[1.2,2.3,3.4,5.6]
[true,true,false,true]
[12345678909876,23456789098765,34567890987654,45678909876543]
[1,2,3,4]
["four","one","three","two"]
["four","three","two","one"]
["four","one","one","two"]
["four","two","one","one"]
"The quick brown fox jumps over the lazy dog."
"The quick brown fox jumps over the lazy dog."
"The quick brown fox jumps over the lazy dog."
-42
17
17
42
-23
1024
-17
8
3.141592653589793
null
null
42.22999954223633
null
23.42
true
false
```
Note the output is platform-dependent.
Example: (5) create a container (array or object) from an initializer list
The example below shows how JSON values are created from initializer lists.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_empty_init_list = json({});
json j_object = { {"one", 1}, {"two", 2} };
json j_array = {1, 2, 3, 4};
json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
// serialize the JSON value
std::cout << j_empty_init_list << '\n';
std::cout << j_object << '\n';
std::cout << j_array << '\n';
std::cout << j_nested_object << '\n';
std::cout << j_nested_array << '\n';
}
```
Output:
```
{}
{"one":1,"two":2}
[1,2,3,4]
{"one":[1],"two":[1,2]}
[[[1],"one"],[[1,2],"two"]]
```
Example: (6) construct an array with count copies of a given value
The following code shows examples for creating arrays with several copies of a given value.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array by creating copies of a JSON value
json value = "Hello";
json array_0 = json(0, value);
json array_1 = json(1, value);
json array_5 = json(5, value);
// serialize the JSON arrays
std::cout << array_0 << '\n';
std::cout << array_1 << '\n';
std::cout << array_5 << '\n';
}
```
Output:
```
[]
["Hello"]
["Hello","Hello","Hello","Hello","Hello"]
```
Example: (7) construct a JSON container given an iterator range
The example below shows several ways to create JSON values by specifying a subrange with iterators.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
json j_number = 42;
json j_object = {{"one", "eins"}, {"two", "zwei"}};
// create copies using iterators
json j_array_range(j_array.begin() + 1, j_array.end() - 2);
json j_number_range(j_number.begin(), j_number.end());
json j_object_range(j_object.begin(), j_object.find("two"));
// serialize the values
std::cout << j_array_range << '\n';
std::cout << j_number_range << '\n';
std::cout << j_object_range << '\n';
// example for an exception
try
{
json j_invalid(j_number.begin() + 1, j_number.end());
}
catch (const json::invalid_iterator& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
["bravo","charly"]
42
{"one":"eins"}
[json.exception.invalid_iterator.204] iterators out of range
```
Example: (8) copy constructor
The following code shows an example for the copy constructor.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON array
json j1 = {"one", "two", 3, 4.5, false};
// create a copy
json j2(j1);
// serialize the JSON array
std::cout << j1 << " = " << j2 << '\n';
std::cout << std::boolalpha << (j1 == j2) << '\n';
}
```
Output:
```
["one","two",3,4.5,false] = ["one","two",3,4.5,false]
true
```
Example: (9) move constructor
The code below shows the move constructor explicitly called via `std::move`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json a = 23;
// move contents of a to b
json b(std::move(a));
// serialize the JSON arrays
std::cout << a << '\n';
std::cout << b << '\n';
}
```
Output:
```
null
23
```
## Version history
1. Since version 1.0.0.
1. Since version 1.0.0.
1. Since version 2.1.0.
1. Since version 3.2.0.
1. Since version 1.0.0.
1. Since version 1.0.0.
1. Since version 1.0.0.
1. Since version 1.0.0.
1. Since version 1.0.0.
-42
View File
@@ -1,42 +0,0 @@
# <small>nlohmann::basic_json::</small>begin
```cpp
iterator begin() noexcept;
const_iterator begin() const noexcept;
```
Returns an iterator to the first element.
![Illustration from cppreference.com](../../images/range-begin-end.svg)
## Return value
iterator to the first element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `begin()`.
```cpp
--8<-- "examples/begin.cpp"
```
Output:
```json
--8<-- "examples/begin.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-55
View File
@@ -1,55 +0,0 @@
# nlohmann::basic_json::begin
```
iterator begin() noexcept;
const_iterator begin() const noexcept;
```
Returns an iterator to the first element.
## Return value
iterator to the first element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The following code shows an example for `begin()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array value
json array = {1, 2, 3, 4, 5};
// get an iterator to the first element
json::iterator it = array.begin();
// serialize the element that the iterator points to
std::cout << *it << '\n';
}
```
Output:
```
1
```
## Version history
- Added in version 1.0.0.
-66
View File
@@ -1,66 +0,0 @@
# <small>nlohmann::basic_json::</small>binary
```cpp
// (1)
static basic_json binary(const typename binary_t::container_type& init);
static basic_json binary(typename binary_t::container_type&& init);
// (2)
static basic_json binary(const typename binary_t::container_type& init,
std::uint8_t subtype);
static basic_json binary(typename binary_t::container_type&& init,
std::uint8_t subtype);
```
1. Creates a JSON binary array value from a given binary container.
2. Creates a JSON binary array value from a given binary container with subtype.
Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to
create a value for serialization to those formats.
## Parameters
`init` (in)
: container containing bytes to use as a binary type
`subtype` (in)
: subtype to use in CBOR, MessagePack, and BSON
## Return value
JSON binary array value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions.
## Notes
Note, this function exists because of the difficulty in correctly specifying the correct template overload in the
standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because
JSON binary arrays are a non-standard extension, it was decided that it would be best to prevent automatic
initialization of a binary array type, for backwards compatibility and so it does not happen on accident.
## Examples
??? example
The following code shows how to create a binary value.
```cpp
--8<-- "examples/binary.cpp"
```
Output:
```json
--8<-- "examples/binary.output"
```
## Version history
- Added in version 3.8.0.
File diff suppressed because one or more lines are too long
-75
View File
@@ -1,75 +0,0 @@
# nlohmann::basic_json::binary
```
// (1)
static basic_json binary(const typename binary_t::container_type& init);
static basic_json binary(typename binary_t::container_type&& init);
// (2)
static basic_json binary(const typename binary_t::container_type& init,
std::uint8_t subtype);
static basic_json binary(typename binary_t::container_type&& init,
std::uint8_t subtype);
```
1. Creates a JSON binary array value from a given binary container.
1. Creates a JSON binary array value from a given binary container with subtype.
Binary values are part of various binary formats, such as CBOR, MessagePack, and BSON. This constructor is used to create a value for serialization to those formats.
## Parameters
`init` (in) : container containing bytes to use as a binary type
`subtype` (in) : subtype to use in CBOR, MessagePack, and BSON
## Return value
JSON binary array value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the size of `init`; constant for `typename binary_t::container_type&& init` versions.
## Notes
Note, this function exists because of the difficulty in correctly specifying the correct template overload in the standard value ctor, as both JSON arrays and JSON binary arrays are backed with some form of a `std::vector`. Because JSON binary arrays are a non-standard extension, it was decided that it would be best to prevent automatic initialization of a binary array type, for backwards compatibility and so it does not happen on accident.
## Examples
Example
The following code shows how to create a binary value.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a binary vector
std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE};
// create a binary JSON value with subtype 42
json j = json::binary(vec, 42);
// output type and subtype
std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
}
```
Output:
```
type: binary, subtype: 42
```
## Version history
- Added in version 3.8.0.
-129
View File
@@ -1,129 +0,0 @@
# <small>nlohmann::basic_json::</small>binary_t
```cpp
using binary_t = byte_container_with_subtype<BinaryType>;
```
This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type
2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for
compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values.
Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint64_t`, which
is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is
incompatible with each other, and it is up to the user to translate between them). The subtype is added to `BinaryType`
via the helper type [byte_container_with_subtype](../byte_container_with_subtype/index.md).
[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as:
> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers
> (major type 0).
[MessagePack's documentation on the bin type
family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as:
> Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array.
[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to
represent the generic binary type which has the description:
> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and
> tools.
None of these impose any limitations on the internal representation other than the basic unit of storage be some type of
array whose parts are decomposable into bytes.
The default representation of this binary format is a `#!cpp std::vector<std::uint8_t>`, which is a very common way to
represent a byte array in modern C++.
## Template parameters
`BinaryType`
: container type to store arrays
Although not formally expressed as a C++ concept, `BinaryType` must be default-constructible,
copy/move-constructible, and support `push_back()`, `.data()`, and `.size()`, because
[`byte_container_with_subtype`](../byte_container_with_subtype/index.md) derives directly from it. Its
`value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary
serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via
`reinterpret_cast`, which is only correct for byte-sized elements -- a container like
`#!cpp std::vector<std::intptr_t>` will not work as `BinaryType`.
## Notes
#### Default type
The default values for `BinaryType` is `#!cpp std::vector<std::uint8_t>`.
#### Custom BinaryType behavior
When a custom `BinaryType` is configured (other than the default `#!cpp std::vector<std::uint8_t>`), you can assign
values of that type directly to a `basic_json` instance, and they will automatically be recognized as binary values
rather than arrays:
```cpp
using custom_json = nlohmann::basic_json<
nlohmann::ordered_map, // ObjectType
std::vector, // ArrayType
std::string, // StringType
bool, // BooleanType
std::int64_t, // NumberIntegerType
std::uint64_t, // NumberUnsignedType
double, // NumberFloatType
std::allocator, // AllocatorType
nlohmann::adl_serializer,
std::vector<std::byte> // Custom BinaryType
>;
std::vector<std::byte> data{std::byte{1}, std::byte{2}, std::byte{3}};
custom_json j = data; // Creates a binary value, not an array
assert(j.is_binary());
// Round-tripping works seamlessly
auto extracted = j.get<std::vector<std::byte>>();
assert(extracted == data);
```
This automatic type detection is a convenience feature that only applies to custom (non-default) `BinaryType` configurations.
The default `nlohmann::json` continues to treat `#!cpp std::vector<std::uint8_t>` as arrays for backward compatibility.
#### Storage
Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the
type `#!cpp binary_t*` must be dereferenced.
#### Notes on subtypes
- CBOR
- Binary values are represented as byte strings. Subtypes are written as tags.
- MessagePack
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1,
fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is
then added as a signed 8-bit integer.
- If no subtype is given, the bin family (bin8, bin16, bin32) is used.
- BSON
- If a subtype is given, it is used and added as an unsigned 8-bit integer.
- If no subtype is given, the generic binary subtype 0x00 is used.
## Examples
??? example
The following code shows that `binary_t` is by default, a typedef to
`#!cpp nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>`.
```cpp
--8<-- "examples/binary_t.cpp"
```
Output:
```json
--8<-- "examples/binary_t.output"
```
## See also
- [byte_container_with_subtype](../byte_container_with_subtype/index.md)
## Version history
- Added in version 3.8.0. Changed the type of subtype to `std::uint64_t` in version 3.10.0.
File diff suppressed because one or more lines are too long
-127
View File
@@ -1,127 +0,0 @@
# nlohmann::basic_json::binary_t
```
using binary_t = byte_container_with_subtype<BinaryType>;
```
This type is a type designed to carry binary data that appears in various serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and BSON's generic binary subtype. This type is NOT a part of standard JSON and exists solely for compatibility with these binary types. As such, it is simply defined as an ordered sequence of zero or more byte values.
Additionally, as an implementation detail, the subtype of the binary data is carried around as a `std::uint64_t`, which is compatible with both of the binary data formats that use binary subtyping, (though the specific numbering is incompatible with each other, and it is up to the user to translate between them). The subtype is added to `BinaryType` via the helper type [byte_container_with_subtype](https://json.nlohmann.me/api/byte_container_with_subtype/index.md).
[CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type as:
> Major type 2: a byte string. The string's length in bytes is represented following the rules for positive integers (major type 0).
[MessagePack's documentation on the bin type family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) describes this type as:
> Bin format family stores a byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array.
[BSON's specifications](http://bsonspec.org/spec.html) describe several binary types; however, this type is intended to represent the generic binary type which has the description:
> Generic binary subtype - This is the most commonly used binary subtype and should be the 'default' for drivers and tools.
None of these impose any limitations on the internal representation other than the basic unit of storage be some type of array whose parts are decomposable into bytes.
The default representation of this binary format is a `std::vector<std::uint8_t>`, which is a very common way to represent a byte array in modern C++.
## Template parameters
`BinaryType` : container type to store arrays
```
Although not formally expressed as a C++ concept, `BinaryType` must be default-constructible,
copy/move-constructible, and support `push_back()`, `.data()`, and `.size()`, because
[`byte_container_with_subtype`](https://json.nlohmann.me/api/byte_container_with_subtype/index.md) derives directly from it. Its
`value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary
serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via
`reinterpret_cast`, which is only correct for byte-sized elements -- a container like
`std::vector<std::intptr_t>` will not work as `BinaryType`.
```
## Notes
#### Default type
The default values for `BinaryType` is `std::vector<std::uint8_t>`.
#### Custom BinaryType behavior
When a custom `BinaryType` is configured (other than the default `std::vector<std::uint8_t>`), you can assign values of that type directly to a `basic_json` instance, and they will automatically be recognized as binary values rather than arrays:
```
using custom_json = nlohmann::basic_json<
nlohmann::ordered_map, // ObjectType
std::vector, // ArrayType
std::string, // StringType
bool, // BooleanType
std::int64_t, // NumberIntegerType
std::uint64_t, // NumberUnsignedType
double, // NumberFloatType
std::allocator, // AllocatorType
nlohmann::adl_serializer,
std::vector<std::byte> // Custom BinaryType
>;
std::vector<std::byte> data{std::byte{1}, std::byte{2}, std::byte{3}};
custom_json j = data; // Creates a binary value, not an array
assert(j.is_binary());
// Round-tripping works seamlessly
auto extracted = j.get<std::vector<std::byte>>();
assert(extracted == data);
```
This automatic type detection is a convenience feature that only applies to custom (non-default) `BinaryType` configurations. The default `nlohmann::json` continues to treat `std::vector<std::uint8_t>` as arrays for backward compatibility.
#### Storage
Binary Arrays are stored as pointers in a `basic_json` type. That is, for any access to array values, a pointer of the type `binary_t*` must be dereferenced.
#### Notes on subtypes
- CBOR
- Binary values are represented as byte strings. Subtypes are written as tags.
- MessagePack
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is then added as a signed 8-bit integer.
- If no subtype is given, the bin family (bin8, bin16, bin32) is used.
- BSON
- If a subtype is given, it is used and added as an unsigned 8-bit integer.
- If no subtype is given, the generic binary subtype 0x00 is used.
## Examples
Example
The following code shows that `binary_t` is by default, a typedef to `nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>`.
```
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << std::endl;
}
```
Output:
```
true
```
## See also
- [byte_container_with_subtype](https://json.nlohmann.me/api/byte_container_with_subtype/index.md)
## Version history
- Added in version 3.8.0. Changed the type of subtype to `std::uint64_t` in version 3.10.0.
-42
View File
@@ -1,42 +0,0 @@
# <small>nlohmann::basic_json::</small>boolean_t
```cpp
using boolean_t = BooleanType;
```
The type used to store JSON booleans.
[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two
literals `#!json true` and `#!json false`.
To store boolean values in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
## Notes
#### Default type
With the default values for `BooleanType` (`#!cpp bool`), the default value for `boolean_t` is `#!cpp bool`.
#### Storage
Boolean values are stored directly inside a `basic_json` type.
## Examples
??? example
The following code shows that `boolean_t` is by default, a typedef to `#!cpp bool`.
```cpp
--8<-- "examples/boolean_t.cpp"
```
Output:
```json
--8<-- "examples/boolean_t.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-50
View File
@@ -1,50 +0,0 @@
# nlohmann::basic_json::boolean_t
```
using boolean_t = BooleanType;
```
The type used to store JSON booleans.
[RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a type which differentiates the two literals `true` and `false`.
To store boolean values in C++, a type is defined by the template parameter `BooleanType` which chooses the type to use.
## Notes
#### Default type
With the default values for `BooleanType` (`bool`), the default value for `boolean_t` is `bool`.
#### Storage
Boolean values are stored directly inside a `basic_json` type.
## Examples
Example
The following code shows that `boolean_t` is by default, a typedef to `bool`.
```
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl;
}
```
Output:
```
true
```
## Version history
- Added in version 1.0.0.
-41
View File
@@ -1,41 +0,0 @@
# <small>nlohmann::basic_json::</small>cbegin
```cpp
const_iterator cbegin() const noexcept;
```
Returns an iterator to the first element.
![Illustration from cppreference.com](../../images/range-begin-end.svg)
## Return value
iterator to the first element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `cbegin()`.
```cpp
--8<-- "examples/cbegin.cpp"
```
Output:
```json
--8<-- "examples/cbegin.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-54
View File
@@ -1,54 +0,0 @@
# nlohmann::basic_json::cbegin
```
const_iterator cbegin() const noexcept;
```
Returns an iterator to the first element.
## Return value
iterator to the first element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The following code shows an example for `cbegin()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array value
const json array = {1, 2, 3, 4, 5};
// get an iterator to the first element
json::const_iterator it = array.cbegin();
// serialize the element that the iterator points to
std::cout << *it << '\n';
}
```
Output:
```
1
```
## Version history
- Added in version 1.0.0.
-42
View File
@@ -1,42 +0,0 @@
# <small>nlohmann::basic_json::</small>cbor_tag_handler_t
```cpp
enum class cbor_tag_handler_t
{
error,
ignore,
store
};
```
This enumeration is used in the [`from_cbor`](from_cbor.md) function to choose how to treat tags:
error
: throw a `parse_error` exception in case of a tag
ignore
: ignore tags
store
: store tagged values as binary container with subtype (for bytes 0xd8..0xdb)
## Examples
??? example
The example below shows how the different values of the `cbor_tag_handler_t` influence the behavior of
[`from_cbor`](from_cbor.md) when reading a tagged byte string.
```cpp
--8<-- "examples/cbor_tag_handler_t.cpp"
```
Output:
```json
--8<-- "examples/cbor_tag_handler_t.output"
```
## Version history
- Added in version 3.9.0. Added value `store` in 3.10.0.
File diff suppressed because one or more lines are too long
@@ -1,67 +0,0 @@
# nlohmann::basic_json::cbor_tag_handler_t
```
enum class cbor_tag_handler_t
{
error,
ignore,
store
};
```
This enumeration is used in the [`from_cbor`](https://json.nlohmann.me/api/basic_json/from_cbor/index.md) function to choose how to treat tags:
error : throw a `parse_error` exception in case of a tag
ignore : ignore tags
store : store tagged values as binary container with subtype (for bytes 0xd8..0xdb)
## Examples
Example
The example below shows how the different values of the `cbor_tag_handler_t` influence the behavior of [`from_cbor`](https://json.nlohmann.me/api/basic_json/from_cbor/index.md) when reading a tagged byte string.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// tagged byte string
std::vector<std::uint8_t> vec = {{0xd8, 0x42, 0x44, 0xcA, 0xfe, 0xba, 0xbe}};
// cbor_tag_handler_t::error throws
try
{
auto b_throw_on_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::error);
}
catch (const json::parse_error& e)
{
std::cout << e.what() << std::endl;
}
// cbor_tag_handler_t::ignore ignores the tag
auto b_ignore_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::ignore);
std::cout << b_ignore_tag << std::endl;
// cbor_tag_handler_t::store stores the tag as binary subtype
auto b_store_tag = json::from_cbor(vec, true, true, json::cbor_tag_handler_t::store);
std::cout << b_store_tag << std::endl;
}
```
Output:
```
[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xD8
{"bytes":[202,254,186,190],"subtype":null}
{"bytes":[202,254,186,190],"subtype":66}
```
## Version history
- Added in version 3.9.0. Added value `store` in 3.10.0.
-41
View File
@@ -1,41 +0,0 @@
# <small>nlohmann::basic_json::</small>cend
```cpp
const_iterator cend() const noexcept;
```
Returns an iterator to one past the last element.
![Illustration from cppreference.com](../../images/range-begin-end.svg)
## Return value
iterator one past the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `cend()`.
```cpp
--8<-- "examples/cend.cpp"
```
Output:
```json
--8<-- "examples/cend.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-57
View File
@@ -1,57 +0,0 @@
# nlohmann::basic_json::cend
```
const_iterator cend() const noexcept;
```
Returns an iterator to one past the last element.
## Return value
iterator one past the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The following code shows an example for `cend()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array value
json array = {1, 2, 3, 4, 5};
// get an iterator to one past the last element
json::const_iterator it = array.cend();
// decrement the iterator to point to the last element
--it;
// serialize the element that the iterator points to
std::cout << *it << '\n';
}
```
Output:
```
5
```
## Version history
- Added in version 1.0.0.
-58
View File
@@ -1,58 +0,0 @@
# <small>nlohmann::basic_json::</small>clear
```cpp
void clear() noexcept;
```
Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](basic_json.md) would
have been called with the current value type from [`type()`](type.md):
| Value type | initial value |
|------------|----------------------|
| null | `null` |
| boolean | `false` |
| string | `""` |
| number | `0` |
| binary | An empty byte vector |
| object | `{}` |
| array | `[]` |
Has the same effect as calling
```.cpp
*this = basic_json(type());
```
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Linear in the size of the JSON value.
## Notes
All iterators, pointers, and references related to this container are invalidated.
## Examples
??? example
The example below shows the effect of `clear()` to different
JSON types.
```cpp
--8<-- "examples/clear.cpp"
```
Output:
```json
--8<-- "examples/clear.output"
```
## Version history
- Added in version 1.0.0.
- Added support for binary types in version 3.8.0.
File diff suppressed because one or more lines are too long
-95
View File
@@ -1,95 +0,0 @@
# nlohmann::basic_json::clear
```
void clear() noexcept;
```
Clears the content of a JSON value and resets it to the default value as if [`basic_json(value_t)`](https://json.nlohmann.me/api/basic_json/basic_json/index.md) would have been called with the current value type from [`type()`](https://json.nlohmann.me/api/basic_json/type/index.md):
| Value type | initial value |
| ---------- | -------------------- |
| null | `null` |
| boolean | `false` |
| string | `""` |
| number | `0` |
| binary | An empty byte vector |
| object | `{}` |
| array | `[]` |
Has the same effect as calling
```
*this = basic_json(type());
```
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Linear in the size of the JSON value.
## Notes
All iterators, pointers, and references related to this container are invalidated.
## Examples
Example
The example below shows the effect of `clear()` to different JSON types.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_null;
json j_boolean = true;
json j_number_integer = 17;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hello, world";
// call clear()
j_null.clear();
j_boolean.clear();
j_number_integer.clear();
j_number_float.clear();
j_object.clear();
j_array.clear();
j_string.clear();
// serialize the cleared values()
std::cout << j_null << '\n';
std::cout << j_boolean << '\n';
std::cout << j_number_integer << '\n';
std::cout << j_number_float << '\n';
std::cout << j_object << '\n';
std::cout << j_array << '\n';
std::cout << j_string << '\n';
}
```
Output:
```
null
false
0
0.0
{}
[]
""
```
## Version history
- Added in version 1.0.0.
- Added support for binary types in version 3.8.0.
-119
View File
@@ -1,119 +0,0 @@
# <small>nlohmann::basic_json::</small>contains
```cpp
// (1)
bool contains(const typename object_t::key_type& key) const;
// (2)
template<typename KeyType>
bool contains(KeyType&& key) const;
// (3)
bool contains(const json_pointer& ptr) const;
```
1. Check whether an element exists in a JSON object with a key equivalent to `key`. If the element is not found or the
JSON value is not an object, `#!cpp false` is returned.
2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and
`#!cpp typename object_comparator_t::is_transparent` denotes a type.
3. Check whether the given JSON pointer `ptr` can be resolved in the current JSON value.
## Template parameters
`KeyType`
: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with
[`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md).
This can also be a string view (C++17).
## Parameters
`key` (in)
: key value to check its existence.
`ptr` (in)
: JSON pointer to check its existence.
## Return value
1. `#!cpp true` if an element with specified `key` exists. If no such element with such a key is found or the JSON value
is not an object, `#!cpp false` is returned.
2. See 1.
3. `#!cpp true` if the JSON pointer can be resolved to a stored value, `#!cpp false` otherwise.
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. The function does not throw exceptions.
2. The function does not throw exceptions.
3. The function does not throw exceptions.
## Complexity
Logarithmic in the size of the JSON object.
## Notes
- This method always returns `#!cpp false` when executed on a JSON type that is not an object.
- This method can be executed on any JSON value type.
!!! info "Postconditions"
If `#!cpp j.contains(x)` returns `#!c true` for a key or JSON pointer `x`, then it is safe to call `j[x]`.
## Examples
??? example "Example: (1) check with key"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/contains__object_t_key_type.output"
```
??? example "Example: (2) check with key using string_view"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/contains__keytype.c++17.output"
```
??? example "Example: (3) check with JSON pointer"
The example shows how `contains()` is used.
```cpp
--8<-- "examples/contains__json_pointer.cpp"
```
Output:
```json
--8<-- "examples/contains__json_pointer.output"
```
## See also
- [find](find.md) find a value in an object
- [count](count.md) returns the number of occurrences of a key
## Version history
1. Added in version 3.11.0.
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0.
3. Added in version 3.7.0.
File diff suppressed because one or more lines are too long
-199
View File
@@ -1,199 +0,0 @@
# nlohmann::basic_json::contains
```
// (1)
bool contains(const typename object_t::key_type& key) const;
// (2)
template<typename KeyType>
bool contains(KeyType&& key) const;
// (3)
bool contains(const json_pointer& ptr) const;
```
1. Check whether an element exists in a JSON object with a key equivalent to `key`. If the element is not found or the JSON value is not an object, `false` is returned.
1. See 1. This overload is only available if `KeyType` is comparable with `typename object_t::key_type` and `typename object_comparator_t::is_transparent` denotes a type.
1. Check whether the given JSON pointer `ptr` can be resolved in the current JSON value.
## Template parameters
`KeyType` : A type for an object key other than [`json_pointer`](https://json.nlohmann.me/api/json_pointer/index.md) that is comparable with [`string_t`](https://json.nlohmann.me/api/basic_json/string_t/index.md) using [`object_comparator_t`](https://json.nlohmann.me/api/basic_json/object_comparator_t/index.md). This can also be a string view (C++17).
## Parameters
`key` (in) : key value to check its existence.
`ptr` (in) : JSON pointer to check its existence.
## Return value
1. `true` if an element with specified `key` exists. If no such element with such a key is found or the JSON value is not an object, `false` is returned.
1. See 1.
1. `true` if the JSON pointer can be resolved to a stored value, `false` otherwise.
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. The function does not throw exceptions.
1. The function does not throw exceptions.
1. The function does not throw exceptions.
## Complexity
Logarithmic in the size of the JSON object.
## Notes
- This method always returns `false` when executed on a JSON type that is not an object.
- This method can be executed on any JSON value type.
Postconditions
If `j.contains(x)` returns `true` for a key or JSON pointer `x`, then it is safe to call `j[x]`.
## Examples
Example: (1) check with key
The example shows how `contains()` is used.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create some JSON values
json j_object = R"( {"key": "value"} )"_json;
json j_array = R"( [1, 2, 3] )"_json;
// call contains
std::cout << std::boolalpha <<
"j_object contains 'key': " << j_object.contains("key") << '\n' <<
"j_object contains 'another': " << j_object.contains("another") << '\n' <<
"j_array contains 'key': " << j_array.contains("key") << std::endl;
}
```
Output:
```
j_object contains 'key': true
j_object contains 'another': false
j_array contains 'key': false
```
Example: (2) check with key using string_view
The example shows how `contains()` is used.
```
#include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create some JSON values
json j_object = R"( {"key": "value"} )"_json;
json j_array = R"( [1, 2, 3] )"_json;
// call contains
std::cout << std::boolalpha <<
"j_object contains 'key': " << j_object.contains("key"sv) << '\n' <<
"j_object contains 'another': " << j_object.contains("another"sv) << '\n' <<
"j_array contains 'key': " << j_array.contains("key"sv) << std::endl;
}
```
Output:
```
j_object contains 'key': true
j_object contains 'another': false
j_array contains 'key': false
```
Example: (3) check with JSON pointer
The example shows how `contains()` is used.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
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 (const 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 (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
true
true
true
true
false
false
false
```
## See also
- [find](https://json.nlohmann.me/api/basic_json/find/index.md) find a value in an object
- [count](https://json.nlohmann.me/api/basic_json/count/index.md) returns the number of occurrences of a key
## Version history
1. Added in version 3.11.0.
1. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0.
1. Added in version 3.7.0.
-83
View File
@@ -1,83 +0,0 @@
# <small>nlohmann::basic_json::</small>count
```cpp
// (1)
size_type count(const typename object_t::key_type& key) const;
// (2)
template<typename KeyType>
size_type count(KeyType&& key) const;
```
1. Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
always be `0` (`key` was not found) or `1` (`key` was found).
2. See 1. This overload is only available if `KeyType` is comparable with `#!cpp typename object_t::key_type` and
`#!cpp typename object_comparator_t::is_transparent` denotes a type.
## Template parameters
`KeyType`
: A type for an object key other than [`json_pointer`](../json_pointer/index.md) that is comparable with
[`string_t`](string_t.md) using [`object_comparator_t`](object_comparator_t.md).
This can also be a string view (C++17).
## Parameters
`key` (in)
: key value of the element to count.
## Return value
Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Complexity
Logarithmic in the size of the JSON object.
## Notes
This method always returns `0` when executed on a JSON type that is not an object.
## Examples
??? example "Example: (1) count number of elements"
The example shows how `count()` is used.
```cpp
--8<-- "examples/count__object_t_key_type.cpp"
```
Output:
```json
--8<-- "examples/count__object_t_key_type.output"
```
??? example "Example: (2) count number of elements using string_view"
The example shows how `count()` is used.
```cpp
--8<-- "examples/count__keytype.c++17.cpp"
```
Output:
```json
--8<-- "examples/count__keytype.c++17.output"
```
## See also
- [find](find.md) find a value in an object
- [contains](contains.md) checks whether a key exists
## Version history
1. Added in version 3.11.0.
2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0.
File diff suppressed because one or more lines are too long
-115
View File
@@ -1,115 +0,0 @@
# nlohmann::basic_json::count
```
// (1)
size_type count(const typename object_t::key_type& key) const;
// (2)
template<typename KeyType>
size_type count(KeyType&& key) const;
```
1. Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will always be `0` (`key` was not found) or `1` (`key` was found).
1. See 1. This overload is only available if `KeyType` is comparable with `typename object_t::key_type` and `typename object_comparator_t::is_transparent` denotes a type.
## Template parameters
`KeyType` : A type for an object key other than [`json_pointer`](https://json.nlohmann.me/api/json_pointer/index.md) that is comparable with [`string_t`](https://json.nlohmann.me/api/basic_json/string_t/index.md) using [`object_comparator_t`](https://json.nlohmann.me/api/basic_json/object_comparator_t/index.md). This can also be a string view (C++17).
## Parameters
`key` (in) : key value of the element to count.
## Return value
Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
## Exception safety
Strong exception safety: if an exception occurs, the original value stays intact.
## Complexity
Logarithmic in the size of the JSON object.
## Notes
This method always returns `0` when executed on a JSON type that is not an object.
## Examples
Example: (1) count number of elements
The example shows how `count()` is used.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call count()
auto count_two = j_object.count("two");
auto count_three = j_object.count("three");
// print values
std::cout << "number of elements with key \"two\": " << count_two << '\n';
std::cout << "number of elements with key \"three\": " << count_three << '\n';
}
```
Output:
```
number of elements with key "two": 1
number of elements with key "three": 0
```
Example: (2) count number of elements using string_view
The example shows how `count()` is used.
```
#include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create a JSON object
json j_object = {{"one", 1}, {"two", 2}};
// call count()
auto count_two = j_object.count("two"sv);
auto count_three = j_object.count("three"sv);
// print values
std::cout << "number of elements with key \"two\": " << count_two << '\n';
std::cout << "number of elements with key \"three\": " << count_three << '\n';
}
```
Output:
```
number of elements with key "two": 1
number of elements with key "three": 0
```
## See also
- [find](https://json.nlohmann.me/api/basic_json/find/index.md) find a value in an object
- [contains](https://json.nlohmann.me/api/basic_json/contains/index.md) checks whether a key exists
## Version history
1. Added in version 3.11.0.
1. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0.
-41
View File
@@ -1,41 +0,0 @@
# <small>nlohmann::basic_json::</small>crbegin
```cpp
const_reverse_iterator crbegin() const noexcept;
```
Returns an iterator to the reverse-beginning; that is, the last element.
![Illustration from cppreference.com](../../images/range-rbegin-rend.svg)
## Return value
reverse iterator to the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `crbegin()`.
```cpp
--8<-- "examples/crbegin.cpp"
```
Output:
```json
--8<-- "examples/crbegin.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-54
View File
@@ -1,54 +0,0 @@
# nlohmann::basic_json::crbegin
```
const_reverse_iterator crbegin() const noexcept;
```
Returns an iterator to the reverse-beginning; that is, the last element.
## Return value
reverse iterator to the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The following code shows an example for `crbegin()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array value
json array = {1, 2, 3, 4, 5};
// get an iterator to the reverse-beginning
json::const_reverse_iterator it = array.crbegin();
// serialize the element that the iterator points to
std::cout << *it << '\n';
}
```
Output:
```
5
```
## Version history
- Added in version 1.0.0.
-42
View File
@@ -1,42 +0,0 @@
# <small>nlohmann::basic_json::</small>crend
```cpp
const_reverse_iterator crend() const noexcept;
```
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
attempting to access it results in undefined behavior.
![Illustration from cppreference.com](../../images/range-rbegin-rend.svg)
## Return value
reverse iterator to the element following the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `crend()`.
```cpp
--8<-- "examples/crend.cpp"
```
Output:
```json
--8<-- "examples/crend.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long
-57
View File
@@ -1,57 +0,0 @@
# nlohmann::basic_json::crend
```
const_reverse_iterator crend() const noexcept;
```
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder, attempting to access it results in undefined behavior.
## Return value
reverse iterator to the element following the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The following code shows an example for `crend()`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array value
json array = {1, 2, 3, 4, 5};
// get an iterator to the reverse-end
json::const_reverse_iterator it = array.crend();
// increment the iterator to point to the first element
--it;
// serialize the element that the iterator points to
std::cout << *it << '\n';
}
```
Output:
```
1
```
## Version history
- Added in version 1.0.0.
@@ -1,35 +0,0 @@
# <small>nlohmann::basic_json::</small>default_object_comparator_t
```cpp
using default_object_comparator_t = std::less<StringType>; // until C++14
using default_object_comparator_t = std::less<>; // since C++14
```
The default comparator used by [`object_t`](object_t.md).
Since C++14 a transparent comparator is used which prevents unnecessary string construction
when looking up a key in an object.
The actual comparator used depends on [`object_t`](object_t.md) and can be obtained via
[`object_comparator_t`](object_comparator_t.md).
## Examples
??? example
The example below demonstrates the default comparator.
```cpp
--8<-- "examples/default_object_comparator_t.cpp"
```
Output:
```json
--8<-- "examples/default_object_comparator_t.output"
```
## Version history
- Added in version 3.11.0.
File diff suppressed because one or more lines are too long
@@ -1,44 +0,0 @@
# nlohmann::basic_json::default_object_comparator_t
```
using default_object_comparator_t = std::less<StringType>; // until C++14
using default_object_comparator_t = std::less<>; // since C++14
```
The default comparator used by [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md).
Since C++14 a transparent comparator is used which prevents unnecessary string construction when looking up a key in an object.
The actual comparator used depends on [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md) and can be obtained via [`object_comparator_t`](https://json.nlohmann.me/api/basic_json/object_comparator_t/index.md).
## Examples
Example
The example below demonstrates the default comparator.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha
<< "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n"
<< "three < four : " << json::default_object_comparator_t{}("three", "four") << std::endl;
}
```
Output:
```
one < two : true
three < four : false
```
## Version history
- Added in version 3.11.0.
-65
View File
@@ -1,65 +0,0 @@
# <small>nlohmann::basic_json::</small>diff
```cpp
static basic_json diff(const basic_json& source,
const basic_json& target);
```
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling
[`patch`](patch.md) function.
For two JSON values `source` and `target`, the following code yields always `#!cpp true`:
```cpp
source.patch(diff(source, target)) == target;
```
## Parameters
`source` (in)
: JSON value to compare from
`target` (in)
: JSON value to compare against
## Return value
a JSON patch to convert the `source` to `target`
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the lengths of `source` and `target`.
## Notes
Currently, only `remove`, `add`, and `replace` operations are generated.
## Examples
??? example
The following code shows how a JSON patch is created as a diff for two JSON values.
```cpp
--8<-- "examples/diff.cpp"
```
Output:
```json
--8<-- "examples/diff.output"
```
## See also
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
- [patch](patch.md) applies a JSON Patch
- [patch_inplace](patch_inplace.md) applies a JSON Patch in place
- [merge_patch](merge_patch.md) applies a JSON Merge Patch
## Version history
- Added in version 2.0.0.
File diff suppressed because one or more lines are too long
-123
View File
@@ -1,123 +0,0 @@
# nlohmann::basic_json::diff
```
static basic_json diff(const basic_json& source,
const basic_json& target);
```
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling [`patch`](https://json.nlohmann.me/api/basic_json/patch/index.md) function.
For two JSON values `source` and `target`, the following code yields always `true`:
```
source.patch(diff(source, target)) == target;
```
## Parameters
`source` (in) : JSON value to compare from
`target` (in) : JSON value to compare against
## Return value
a JSON patch to convert the `source` to `target`
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
## Complexity
Linear in the lengths of `source` and `target`.
## Notes
Currently, only `remove`, `add`, and `replace` operations are generated.
## Examples
Example
The following code shows how a JSON patch is created as a diff for two JSON values.
```
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// the source document
json source = R"(
{
"baz": "qux",
"foo": "bar"
}
)"_json;
// the target document
json target = R"(
{
"baz": "boo",
"hello": [
"world"
]
}
)"_json;
// create the patch
json patch = json::diff(source, target);
// roundtrip
json patched_source = source.patch(patch);
// output patch and roundtrip result
std::cout << std::setw(4) << patch << "\n\n"
<< std::setw(4) << patched_source << std::endl;
}
```
Output:
```
[
{
"op": "replace",
"path": "/baz",
"value": "boo"
},
{
"op": "remove",
"path": "/foo"
},
{
"op": "add",
"path": "/hello",
"value": [
"world"
]
}
]
{
"baz": "boo",
"hello": [
"world"
]
}
```
## See also
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
- [patch](https://json.nlohmann.me/api/basic_json/patch/index.md) applies a JSON Patch
- [patch_inplace](https://json.nlohmann.me/api/basic_json/patch_inplace/index.md) applies a JSON Patch in place
- [merge_patch](https://json.nlohmann.me/api/basic_json/merge_patch/index.md) applies a JSON Merge Patch
## Version history
- Added in version 2.0.0.
-85
View File
@@ -1,85 +0,0 @@
# <small>nlohmann::basic_json::</small>dump
```cpp
string_t dump(const int indent = -1,
const char indent_char = ' ',
const bool ensure_ascii = false,
const error_handler_t error_handler = error_handler_t::strict) const;
```
Serialization function for JSON values. The function tries to mimic Python's
[`json.dumps()` function](https://docs.python.org/2/library/json.html#json.dump), and currently supports its `indent`
and `ensure_ascii` parameters.
## Parameters
`indent` (in)
: If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An
indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation.
`indent_char` (in)
: The character to use for indentation if `indent` is greater than `0`. The default is ` ` (space).
`ensure_ascii` (in)
: If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the
result consists of ASCII characters only.
`error_handler` (in)
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md):
`strict` (throws an exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all valid bytes are copied to the
output unchanged, and invalid bytes are dropped)).
## Return value
string containing the serialization of the JSON value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
## Exceptions
Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value
is not UTF-8 encoded and `error_handler` is set to `strict`
## Complexity
Linear.
## Notes
Binary values are serialized as an object containing two keys:
- "bytes": an array of bytes as integers
- "subtype": the subtype as integer or `#!json null` if the binary has no subtype
## Examples
??? example
The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the
result of the serialization.
```cpp
--8<-- "examples/dump.cpp"
```
Output:
```json
--8<-- "examples/dump.output"
```
## See also
- [to_string](to_string.md) returns a string representation of a JSON value
- [operator<<](../operator_ltlt.md) serialize to stream
- [Serialization](../../features/serialization.md) - the serialization article
## Version history
- Added in version 1.0.0.
- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0.
- Error handlers added in version 3.4.0.
- Serialization of binary values added in version 3.8.0.
File diff suppressed because one or more lines are too long
-173
View File
@@ -1,173 +0,0 @@
# nlohmann::basic_json::dump
```
string_t dump(const int indent = -1,
const char indent_char = ' ',
const bool ensure_ascii = false,
const error_handler_t error_handler = error_handler_t::strict) const;
```
Serialization function for JSON values. The function tries to mimic Python's [`json.dumps()` function](https://docs.python.org/2/library/json.html#json.dump), and currently supports its `indent` and `ensure_ascii` parameters.
## Parameters
`indent` (in) : If `indent` is nonnegative, then array elements and object members will be pretty-printed with that indent level. An indent level of `0` will only insert newlines. `-1` (the default) selects the most compact representation.
`indent_char` (in) : The character to use for indentation if `indent` is greater than `0`. The default is (space).
`ensure_ascii` (in) : If `ensure_ascii` is true, all non-ASCII characters in the output are escaped with `\uXXXX` sequences, and the result consists of ASCII characters only.
`error_handler` (in) : how to react on decoding errors; there are three possible values (see [`error_handler_t`](https://json.nlohmann.me/api/basic_json/error_handler_t/index.md): `strict` (throws an exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all valid bytes are copied to the output unchanged, and invalid bytes are dropped)).
## Return value
string containing the serialization of the JSON value
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
## Exceptions
Throws [`type_error.316`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error316) if a string stored inside the JSON value is not UTF-8 encoded and `error_handler` is set to `strict`
## Complexity
Linear.
## Notes
Binary values are serialized as an object containing two keys:
- "bytes": an array of bytes as integers
- "subtype": the subtype as integer or `null` if the binary has no subtype
## Examples
Example
The following example shows the effect of different `indent`, `indent_char`, and `ensure_ascii` parameters to the result of the serialization.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
json j_string = "Hellö 😀!";
// call dump()
std::cout << "objects:" << '\n'
<< j_object.dump() << "\n\n"
<< j_object.dump(-1) << "\n\n"
<< j_object.dump(0) << "\n\n"
<< j_object.dump(4) << "\n\n"
<< j_object.dump(1, '\t') << "\n\n";
std::cout << "arrays:" << '\n'
<< j_array.dump() << "\n\n"
<< j_array.dump(-1) << "\n\n"
<< j_array.dump(0) << "\n\n"
<< j_array.dump(4) << "\n\n"
<< j_array.dump(1, '\t') << "\n\n";
std::cout << "strings:" << '\n'
<< j_string.dump() << '\n'
<< j_string.dump(-1, ' ', true) << '\n';
// create JSON value with invalid UTF-8 byte sequence
json j_invalid = "ä\xA9ü";
try
{
std::cout << j_invalid.dump() << std::endl;
}
catch (const json::type_error& e)
{
std::cout << e.what() << std::endl;
}
std::cout << "string with replaced invalid characters: "
<< j_invalid.dump(-1, ' ', false, json::error_handler_t::replace)
<< "\nstring with ignored invalid characters: "
<< j_invalid.dump(-1, ' ', false, json::error_handler_t::ignore)
<< '\n';
}
```
Output:
```
objects:
{"one":1,"two":2}
{"one":1,"two":2}
{
"one": 1,
"two": 2
}
{
"one": 1,
"two": 2
}
{
"one": 1,
"two": 2
}
arrays:
[1,2,4,8,16]
[1,2,4,8,16]
[
1,
2,
4,
8,
16
]
[
1,
2,
4,
8,
16
]
[
1,
2,
4,
8,
16
]
strings:
"Hellö 😀!"
"Hell\u00f6 \ud83d\ude00!"
[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9
string with replaced invalid characters: "äü"
string with ignored invalid characters: "äü"
```
## See also
- [to_string](https://json.nlohmann.me/api/basic_json/to_string/index.md) returns a string representation of a JSON value
- [operator\<<](https://json.nlohmann.me/api/operator_ltlt/index.md) serialize to stream
- [Serialization](https://json.nlohmann.me/features/serialization/index.md) - the serialization article
## Version history
- Added in version 1.0.0.
- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0.
- Error handlers added in version 3.4.0.
- Serialization of binary values added in version 3.8.0.
-71
View File
@@ -1,71 +0,0 @@
# <small>nlohmann::basic_json::</small>emplace
```cpp
template<class... Args>
std::pair<iterator, bool> emplace(Args&& ... args);
```
Inserts a new element into a JSON object constructed in-place with the given `args` if there is no element with the key
in the container. If the function is called on a JSON null value, an empty object is created before appending the value
created from `args`.
## Template parameters
`Args`
: compatible types to create a `basic_json` object
## Iterator invalidation
For [`ordered_json`](../ordered_json.md), adding a value to an object can yield a reallocation, in which case all
iterators (including the `end()` iterator) and all references to the elements are invalidated.
## Parameters
`args` (in)
: arguments to forward to a constructor of `basic_json`
## Return value
a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and
a `#!cpp bool` denoting whether the insertion took place.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
## Exceptions
Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
object or `#!json null`; example: `"cannot use emplace() with number"`
## Complexity
Logarithmic in the size of the container, O(log(`size()`)).
## Examples
??? example
The example shows how `emplace()` can be used to add elements to a JSON object. Note how the `#!json null` value was
silently converted to a JSON object. Further note how no value is added if there was already one value stored with
the same key.
```cpp
--8<-- "examples/emplace.cpp"
```
Output:
```json
--8<-- "examples/emplace.output"
```
## See also
- [emplace_back](emplace_back.md) add a value to an array
- [insert](insert.md) add values to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history
- Since version 2.0.8.
File diff suppressed because one or more lines are too long
-97
View File
@@ -1,97 +0,0 @@
# nlohmann::basic_json::emplace
```
template<class... Args>
std::pair<iterator, bool> emplace(Args&& ... args);
```
Inserts a new element into a JSON object constructed in-place with the given `args` if there is no element with the key in the container. If the function is called on a JSON null value, an empty object is created before appending the value created from `args`.
## Template parameters
`Args` : compatible types to create a `basic_json` object
## Iterator invalidation
For [`ordered_json`](https://json.nlohmann.me/api/ordered_json/index.md), adding a value to an object can yield a reallocation, in which case all iterators (including the `end()` iterator) and all references to the elements are invalidated.
## Parameters
`args` (in) : arguments to forward to a constructor of `basic_json`
## Return value
a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a `bool` denoting whether the insertion took place.
## Exception safety
Strong guarantee: if an exception is thrown, there are no changes to any JSON value.
## Exceptions
Throws [`type_error.311`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error311) when called on a type other than JSON object or `null`; example: `"cannot use emplace() with number"`
## Complexity
Logarithmic in the size of the container, O(log(`size()`)).
## Examples
Example
The example shows how `emplace()` can be used to add elements to a JSON object. Note how the `null` value was silently converted to a JSON object. Further note how no value is added if there was already one value stored with the same key.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json object = {{"one", 1}, {"two", 2}};
json null;
// print values
std::cout << object << '\n';
std::cout << null << '\n';
// add values
auto res1 = object.emplace("three", 3);
null.emplace("A", "a");
null.emplace("B", "b");
// the following call will not add an object, because there is already
// a value stored at key "B"
auto res2 = null.emplace("B", "c");
// print values
std::cout << object << '\n';
std::cout << *res1.first << " " << std::boolalpha << res1.second << '\n';
std::cout << null << '\n';
std::cout << *res2.first << " " << std::boolalpha << res2.second << '\n';
}
```
Output:
```
{"one":1,"two":2}
null
{"one":1,"three":3,"two":2}
3 true
{"A":"a","B":"b"}
"b" false
```
## See also
- [emplace_back](https://json.nlohmann.me/api/basic_json/emplace_back/index.md) add a value to an array
- [insert](https://json.nlohmann.me/api/basic_json/insert/index.md) add values to an array/object
- [Modifying values](https://json.nlohmann.me/features/modifying_values/index.md) - the article on modifying values
## Version history
- Since version 2.0.8.
-66
View File
@@ -1,66 +0,0 @@
# <small>nlohmann::basic_json::</small>emplace_back
```cpp
template<class... Args>
reference emplace_back(Args&& ... args);
```
Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON
`#!json null` value, an empty array is created before appending the value created from `args`.
## Template parameters
`Args`
: compatible types to create a `basic_json` object
## Iterator invalidation
By adding an element to the end of the array, a reallocation can happen, in which case all iterators (including the
[`end()`](end.md) iterator) and all references to the elements are invalidated. Otherwise, only the [`end()`](end.md)
iterator is invalidated.
## Parameters
`args` (in)
: arguments to forward to a constructor of `basic_json`
## Return value
reference to the inserted element
## Exceptions
Throws [`type_error.311`](../../home/exceptions.md#jsonexceptiontype_error311) when called on a type other than JSON
array or `#!json null`; example: `"cannot use emplace_back() with number"`
## Complexity
Amortized constant.
## Examples
??? example
The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was
silently converted to a JSON array.
```cpp
--8<-- "examples/emplace_back.cpp"
```
Output:
```json
--8<-- "examples/emplace_back.output"
```
## See also
- [operator+=](operator+=.md) add a value to an array/object
- [push_back](push_back.md) add a value to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history
- Since version 2.0.8.
- Returns reference since 3.7.0.
File diff suppressed because one or more lines are too long
-85
View File
@@ -1,85 +0,0 @@
# nlohmann::basic_json::emplace_back
```
template<class... Args>
reference emplace_back(Args&& ... args);
```
Creates a JSON value from the passed parameters `args` to the end of the JSON value. If the function is called on a JSON `null` value, an empty array is created before appending the value created from `args`.
## Template parameters
`Args` : compatible types to create a `basic_json` object
## Iterator invalidation
By adding an element to the end of the array, a reallocation can happen, in which case all iterators (including the [`end()`](https://json.nlohmann.me/api/basic_json/end/index.md) iterator) and all references to the elements are invalidated. Otherwise, only the [`end()`](https://json.nlohmann.me/api/basic_json/end/index.md) iterator is invalidated.
## Parameters
`args` (in) : arguments to forward to a constructor of `basic_json`
## Return value
reference to the inserted element
## Exceptions
Throws [`type_error.311`](https://json.nlohmann.me/home/exceptions/#jsonexceptiontype_error311) when called on a type other than JSON array or `null`; example: `"cannot use emplace_back() with number"`
## Complexity
Amortized constant.
## Examples
Example
The example shows how `emplace_back()` can be used to add elements to a JSON array. Note how the `null` value was silently converted to a JSON array.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json array = {1, 2, 3, 4, 5};
json null;
// print values
std::cout << array << '\n';
std::cout << null << '\n';
// add values
array.emplace_back(6);
null.emplace_back("first");
null.emplace_back(3, "second");
// print values
std::cout << array << '\n';
std::cout << null << '\n';
}
```
Output:
```
[1,2,3,4,5]
null
[1,2,3,4,5,6]
["first",["second","second","second"]]
```
## See also
- [operator+=](https://json.nlohmann.me/api/basic_json/operator%2B%3D/index.md) add a value to an array/object
- [push_back](https://json.nlohmann.me/api/basic_json/push_back/index.md) add a value to an array/object
- [Modifying values](https://json.nlohmann.me/features/modifying_values/index.md) - the article on modifying values
## Version history
- Since version 2.0.8.
- Returns reference since 3.7.0.
-66
View File
@@ -1,66 +0,0 @@
# <small>nlohmann::basic_json::</small>empty
```cpp
bool empty() const noexcept;
```
Checks if a JSON value has no elements (i.e., whether its [`size()`](size.md) is `0`).
## Return value
The return value depends on the different types and is defined as follows:
| Value type | return value |
|------------|----------------------------------------|
| null | `#!cpp true` |
| boolean | `#!cpp false` |
| string | `#!cpp false` |
| number | `#!cpp false` |
| binary | `#!cpp false` |
| object | result of function `object_t::empty()` |
| array | result of function `array_t::empty()` |
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Constant, as long as [`array_t`](array_t.md) and [`object_t`](object_t.md) satisfy the
[Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have
constant complexity.
## Possible implementation
```cpp
bool empty() const noexcept
{
return size() == 0;
}
```
## Notes
This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container
itself is empty which is `#!cpp false` in the case of a string.
## Examples
??? example
The following code uses `empty()` to check if a JSON object contains any elements.
```cpp
--8<-- "examples/empty.cpp"
```
Output:
```json
--8<-- "examples/empty.output"
```
## Version history
- Added in version 1.0.0.
- Extended to return `#!cpp false` for binary types in version 3.8.0.
File diff suppressed because one or more lines are too long
-100
View File
@@ -1,100 +0,0 @@
# nlohmann::basic_json::empty
```
bool empty() const noexcept;
```
Checks if a JSON value has no elements (i.e., whether its [`size()`](https://json.nlohmann.me/api/basic_json/size/index.md) is `0`).
## Return value
The return value depends on the different types and is defined as follows:
| Value type | return value |
| ---------- | -------------------------------------- |
| null | `true` |
| boolean | `false` |
| string | `false` |
| number | `false` |
| binary | `false` |
| object | result of function `object_t::empty()` |
| array | result of function `array_t::empty()` |
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Constant, as long as [`array_t`](https://json.nlohmann.me/api/basic_json/array_t/index.md) and [`object_t`](https://json.nlohmann.me/api/basic_json/object_t/index.md) satisfy the [Container](https://en.cppreference.com/w/cpp/named_req/Container) concept; that is, their `empty()` functions have constant complexity.
## Possible implementation
```
bool empty() const noexcept
{
return size() == 0;
}
```
## Notes
This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container itself is empty which is `false` in the case of a string.
## Examples
Example
The following code uses `empty()` to check if a JSON object contains any elements.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_null;
json j_boolean = true;
json j_number_integer = 17;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_object_empty(json::value_t::object);
json j_array = {1, 2, 4, 8, 16};
json j_array_empty(json::value_t::array);
json j_string = "Hello, world";
// call empty()
std::cout << std::boolalpha;
std::cout << j_null.empty() << '\n';
std::cout << j_boolean.empty() << '\n';
std::cout << j_number_integer.empty() << '\n';
std::cout << j_number_float.empty() << '\n';
std::cout << j_object.empty() << '\n';
std::cout << j_object_empty.empty() << '\n';
std::cout << j_array.empty() << '\n';
std::cout << j_array_empty.empty() << '\n';
std::cout << j_string.empty() << '\n';
}
```
Output:
```
true
false
false
false
false
true
false
true
false
```
## Version history
- Added in version 1.0.0.
- Extended to return `false` for binary types in version 3.8.0.
-42
View File
@@ -1,42 +0,0 @@
# <small>nlohmann::basic_json::</small>end
```cpp
iterator end() noexcept;
const_iterator end() const noexcept;
```
Returns an iterator to one past the last element.
![Illustration from cppreference.com](../../images/range-begin-end.svg)
## Return value
iterator one past the last element
## Exception safety
No-throw guarantee: this member function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The following code shows an example for `end()`.
```cpp
--8<-- "examples/end.cpp"
```
Output:
```json
--8<-- "examples/end.output"
```
## Version history
- Added in version 1.0.0.
File diff suppressed because one or more lines are too long

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