partial fix for #4358

This commit is contained in:
Muhammad Arif bin Mohamad Ghazaly 2024-11-30 16:54:52 -05:00
parent 765e7536b5
commit dbfc89891c
2 changed files with 30 additions and 8 deletions

View File

@ -378,8 +378,19 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val)
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
break; break;
} }
case value_t::boolean: case value_t::boolean:
{
if ((sizeof(ArithmeticType) == 1) && std::is_unsigned<ArithmeticType>::value)
{
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
}
else
{
get_arithmetic_value(j, val);
}
break;
}
case value_t::null: case value_t::null:
case value_t::object: case value_t::object:
case value_t::array: case value_t::array:

View File

@ -5051,8 +5051,19 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val)
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
break; break;
} }
case value_t::boolean: case value_t::boolean:
{
if ((sizeof(ArithmeticType) == 1) && std::is_unsigned<ArithmeticType>::value)
{
val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
}
else
{
get_arithmetic_value(j, val);
}
break;
}
case value_t::null: case value_t::null:
case value_t::object: case value_t::object:
case value_t::array: case value_t::array: