mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
AK: Make JsonParser correctly parse unsigned values larger than u32
Prior to this, it'd try to stuff them into an i64, which could fail and give us nothing. Even though this is an extension we've made to JSON, the parser should be able to correctly round-trip from whatever our serialiser has generated.
This commit is contained in:
committed by
Andreas Kling
parent
2404ad6897
commit
5d170810db
@@ -263,9 +263,13 @@ Optional<JsonValue> JsonParser::parse_number()
|
||||
value = JsonValue((double)whole + ((double)fraction / divider));
|
||||
} else {
|
||||
#endif
|
||||
auto to_unsigned_result = number_string.to_uint();
|
||||
auto to_unsigned_result = number_string.to_uint<u64>();
|
||||
if (to_unsigned_result.has_value()) {
|
||||
value = JsonValue(to_unsigned_result.value());
|
||||
auto number = *to_unsigned_result;
|
||||
if (number <= NumericLimits<u32>::max())
|
||||
value = JsonValue((u32)number);
|
||||
else
|
||||
value = JsonValue(number);
|
||||
} else {
|
||||
auto number = number_string.to_int<i64>();
|
||||
if (!number.has_value())
|
||||
|
||||
Reference in New Issue
Block a user