From cdf5327ace25503efb22a9c3c8a07753b11b655b Mon Sep 17 00:00:00 2001 From: chenguoping Date: Thu, 14 May 2020 12:44:30 +0800 Subject: [PATCH 1/8] Fix issue#2086 --- include/nlohmann/json.hpp | 3 ++- single_include/nlohmann/json.hpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 9b26dd704..f7216673c 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3759,7 +3759,8 @@ class basic_json @since version 1.0.0 */ template::value, int>::type = 0> + std::is_convertible::value + and not std::is_same::value, int>::type = 0> ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f5abd465c..af66b3200 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19205,7 +19205,8 @@ class basic_json @since version 1.0.0 */ template::value, int>::type = 0> + std::is_convertible::value + and not std::is_same::value, int>::type = 0> ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects From bf4a090075f8795025f50789642dc00698d3f94d Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:12:54 -0400 Subject: [PATCH 2/8] Rename `build` job to `build_stable` to be more descriptive. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 06a64d03c..5db13b1dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2 jobs: - build: + build_stable: docker: - image: debian:stretch From eff2f510713b0ddf6402b15b11ec8ae5fc420909 Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:14:49 -0400 Subject: [PATCH 3/8] Add `build_bleeding_edge` job to CircleCI, mimicking the original job except using the latest Arch Linux docker image. --- .circleci/config.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5db13b1dd..bac3d46a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,3 +22,26 @@ jobs: - run: name: Execute test suite command: 'cd build ; ctest --output-on-failure -j 2' + + build_bleeding_edge: + docker: + - image: archlinux + + steps: + - checkout + + - run: + name: Install required tools + command: 'pacman -S --noconfirm gcc git cmake' + - run: + name: Show versions + command: 'g++ --version ; uname -a; cmake --version' + - run: + name: Run CMake + command: 'mkdir build ; cd build ; cmake ..' + - run: + name: Compile + command: 'cmake --build build' + - run: + name: Execute test suite + command: 'cd build ; ctest --output-on-failure -j 2' \ No newline at end of file From 41a84b1202b9bf0c8870f8a6c22f900d1aba5089 Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:17:02 -0400 Subject: [PATCH 4/8] Add workflows for CircleCI so that `build_stable` and `build_bleeding_edge` jobs can run concurrently. --- .circleci/config.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bac3d46a9..426a56d58 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,4 +44,11 @@ jobs: command: 'cmake --build build' - run: name: Execute test suite - command: 'cd build ; ctest --output-on-failure -j 2' \ No newline at end of file + command: 'cd build ; ctest --output-on-failure -j 2' + +workflows: + version: 2 + build_and_test_all: + jobs: + - build_stable + - build_bleeding_edge From 1d57ddd2d4f3216ca9cf3d32d4048a99053cfcef Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:24:54 -0400 Subject: [PATCH 5/8] Add -y flag to pacman to sync repos. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 426a56d58..045752707 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,7 +32,7 @@ jobs: - run: name: Install required tools - command: 'pacman -S --noconfirm gcc git cmake' + command: 'pacman -Sy --noconfirm gcc git cmake' - run: name: Show versions command: 'g++ --version ; uname -a; cmake --version' From 5a72cfa0c339f91918bb652e16fe5c250812e047 Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:43:15 -0400 Subject: [PATCH 6/8] Add base and base-devel to list of arch linux programs to install. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 045752707..794b21d30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,7 +32,7 @@ jobs: - run: name: Install required tools - command: 'pacman -Sy --noconfirm gcc git cmake' + command: 'pacman -Sy --noconfirm base base-devel gcc git cmake' - run: name: Show versions command: 'g++ --version ; uname -a; cmake --version' From 49000cd77dd43ed1331b1f335dd9f609efbce5f7 Mon Sep 17 00:00:00 2001 From: Antony Kellermann Date: Mon, 25 May 2020 20:46:39 -0400 Subject: [PATCH 7/8] Update documentation to reflect addition of Arch Linux CI testing. --- .github/CONTRIBUTING.md | 2 +- README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 724667c92..7f12d5070 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -66,6 +66,6 @@ To make changes, you need to edit the following files: The following areas really need contribution: -- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions of GCC or Clang. +- Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the bleeding-edge versions Clang. - Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for parsing. - Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency is not everything, speed and memory consumption are very important characteristics for C++ developers, so having proper comparisons would be interesting. diff --git a/README.md b/README.md index 899d56603..3ae3f7993 100644 --- a/README.md +++ b/README.md @@ -1085,7 +1085,7 @@ auto cbor = json::to_msgpack(j); // 0xD5 (fixext2), 0x10, 0xCA, 0xFE Though it's 2020 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: -- GCC 4.8 - 10.0 (and possibly later) +- GCC 4.8 - 10.1 (and possibly later) - Clang 3.4 - 10.0 (and possibly later) - Intel C++ Compiler 17.0.2 (and possibly later) - Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later) @@ -1142,6 +1142,7 @@ The following compilers are currently used in continuous integration at [Travis] | GCC 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) | Ubuntu 18.04.4 LTS | GitHub Actions | | GCC 8.4.0 (Ubuntu 8.4.0-1ubuntu1~14.04) | Ubuntu 14.04.5 LTS | Travis | | GCC 9.3.0 (Ubuntu 9.3.0-11ubuntu0~14.04) | Ubuntu 14.04.5 LTS | Travis | +| GCC 10.1.0 (Arch Linux latest) | Arch Linux | Circle CI | | MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor | | MSVC 19.16.27035.0 (15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor | | MSVC 19.25.28614.0 (Build Engine version 16.5.0+d4cbfca49 for .NET Framework) | Windows-10.0.17763 | AppVeyor | From 27fe50dc92ca069deaefd6f255e59b74eaf00ef7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 26 May 2020 12:46:04 +0200 Subject: [PATCH 8/8] :memo: add example for contains #2133 Closes #2133. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 3ae3f7993..077a60bc6 100644 --- a/README.md +++ b/README.md @@ -544,6 +544,11 @@ for (auto& [key, value] : o.items()) { } // find an entry +if (o.contains("foo")) { + // there is an entry with key "foo" +} + +// or via find and an iterator if (o.find("foo") != o.end()) { // there is an entry with key "foo" }