From edd24629e06368211863b5ce266ff0a2bbb56b20 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 24 Mar 2021 20:32:08 +0100 Subject: [PATCH] :bug: add missing negation --- include/nlohmann/json.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 546cc57e7..fc438bd87 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3500,7 +3500,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec reference at(const KeyType& key) { // at only works for objects - if (JSON_HEDLEY_UNLIKELY(is_object())) + if (JSON_HEDLEY_UNLIKELY(!is_object())) { JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); } @@ -3551,7 +3551,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec const_reference at(const KeyType& key) const { // at only works for objects - if (JSON_HEDLEY_UNLIKELY(is_object())) + if (JSON_HEDLEY_UNLIKELY(!is_object())) { JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); }