mirror of
https://github.com/nlohmann/json.git
synced 2026-11-22 02:44:22 +00:00
check for is_number_unsigned before is_number_integer
This commit is contained in:
1 parent
cb3d455bd2
commit
e678c075dd
1 file changed
+7
-6
+7
-6
@@ -493,10 +493,11 @@ template <typename Json, typename ArithmeticType,
|
|||||||
int> = 0>
|
int> = 0>
|
||||||
void get_arithmetic_value(Json const &j, ArithmeticType &val)
|
void get_arithmetic_value(Json const &j, ArithmeticType &val)
|
||||||
{
|
{
|
||||||
if (j.is_number_integer())
|
// unsigned must be checked first, since is_number_integer() == true for unsigned
|
||||||
val = *j.template get_ptr<const typename Json::number_integer_t*>();
|
if (j.is_number_unsigned())
|
||||||
else if (j.is_number_unsigned())
|
|
||||||
val = *j.template get_ptr<const typename Json::number_unsigned_t*>();
|
val = *j.template get_ptr<const typename Json::number_unsigned_t*>();
|
||||||
|
else if (j.is_number_integer())
|
||||||
|
val = *j.template get_ptr<const typename Json::number_integer_t*>();
|
||||||
else if (j.is_number_float())
|
else if (j.is_number_float())
|
||||||
val = *j.template get_ptr<const typename Json::number_float_t*>();
|
val = *j.template get_ptr<const typename Json::number_float_t*>();
|
||||||
else
|
else
|
||||||
@@ -702,10 +703,10 @@ template <
|
|||||||
int> = 0>
|
int> = 0>
|
||||||
void from_json(Json const &j, ArithmeticType &val)
|
void from_json(Json const &j, ArithmeticType &val)
|
||||||
{
|
{
|
||||||
if (j.is_number_integer())
|
if (j.is_number_unsigned())
|
||||||
val = *j.template get_ptr<const typename Json::number_integer_t*>();
|
|
||||||
else if (j.is_number_unsigned())
|
|
||||||
val = *j.template get_ptr<const typename Json::number_unsigned_t*>();
|
val = *j.template get_ptr<const typename Json::number_unsigned_t*>();
|
||||||
|
else if (j.is_number_integer())
|
||||||
|
val = *j.template get_ptr<const typename Json::number_integer_t*>();
|
||||||
else if (j.is_number_float())
|
else if (j.is_number_float())
|
||||||
val = *j.template get_ptr<const typename Json::number_float_t*>();
|
val = *j.template get_ptr<const typename Json::number_float_t*>();
|
||||||
else if (j.is_boolean())
|
else if (j.is_boolean())
|
||||||
|
|||||||
Reference in new issue
Block a user