From 567c2d2c9377a96e1551a03b8bf66c9e58dbd9d7 Mon Sep 17 00:00:00 2001 From: Muhammad Arif bin Mohamad Ghazaly Date: Tue, 3 Dec 2024 16:45:17 -0500 Subject: [PATCH] Potential fix to previous commit --- include/nlohmann/detail/conversions/from_json.hpp | 11 ++++------- single_include/nlohmann/json.hpp | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 6b04ce289..9f9139b80 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -90,11 +90,12 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) break; } + + case value_t::boolean: case value_t::null: case value_t::object: case value_t::array: case value_t::string: - case value_t::boolean: case value_t::binary: case value_t::discarded: default: @@ -380,15 +381,11 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val) } case value_t::boolean: { - if ((sizeof(ArithmeticType) == 1) && std::is_unsigned::value) + if (std::is_same::value || std::is_same::value) { val = static_cast(*j.template get_ptr()); + break; } - else - { - get_arithmetic_value(j, val); - } - break; } case value_t::null: diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 033889689..3e3b234c0 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4763,11 +4763,12 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) break; } + + case value_t::boolean: case value_t::null: case value_t::object: case value_t::array: case value_t::string: - case value_t::boolean: case value_t::binary: case value_t::discarded: default: @@ -5053,15 +5054,11 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val) } case value_t::boolean: { - if ((sizeof(ArithmeticType) == 1) && std::is_unsigned::value) + if (std::is_same::value || std::is_same::value) { val = static_cast(*j.template get_ptr()); + break; } - else - { - get_arithmetic_value(j, val); - } - break; } case value_t::null: