Fix JSON integer parsing
This commit is contained in:
parent
04d24b22bd
commit
97680827b8
|
@ -261,7 +261,7 @@ parse_json(const char* pos, const char* end)
|
||||||
{
|
{
|
||||||
auto digit_end = pos;
|
auto digit_end = pos;
|
||||||
skip_while(digit_end, end, is_digit);
|
skip_while(digit_end, end, is_digit);
|
||||||
return Result{ Value{str_to_int({pos, end})}, digit_end };
|
return Result{ Value{str_to_int({pos, digit_end})}, digit_end };
|
||||||
}
|
}
|
||||||
if (end - pos > 4 and StringView{pos, pos+4} == "true")
|
if (end - pos > 4 and StringView{pos, pos+4} == "true")
|
||||||
return Result{ Value{true}, pos+4 };
|
return Result{ Value{true}, pos+4 };
|
||||||
|
@ -461,6 +461,12 @@ UnitTest test_json_parser{[]()
|
||||||
kak_assert(value);
|
kak_assert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto value = std::get<0>(parse_json("[10,20]"));
|
||||||
|
kak_assert(value and value.is_a<JsonArray>());
|
||||||
|
kak_assert(value.as<JsonArray>().at(1).as<int>() == 20);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto value = std::get<0>(parse_json("{}"));
|
auto value = std::get<0>(parse_json("{}"));
|
||||||
kak_assert(value and value.is_a<JsonObject>());
|
kak_assert(value and value.is_a<JsonObject>());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user