mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
JsonParser: "" is an empty string, not a null value
This commit is contained in:
parent
f6fe56d011
commit
1ac963b5c8
2 changed files with 9 additions and 1 deletions
|
@ -101,7 +101,7 @@ String JsonParser::consume_quoted_string()
|
||||||
consume_specific('"');
|
consume_specific('"');
|
||||||
|
|
||||||
if (buffer.is_empty())
|
if (buffer.is_empty())
|
||||||
return {};
|
return String::empty();
|
||||||
|
|
||||||
auto& last_string_starting_with_character = m_last_string_starting_with_character[(int)buffer.first()];
|
auto& last_string_starting_with_character = m_last_string_starting_with_character[(int)buffer.first()];
|
||||||
if (last_string_starting_with_character.length() == buffer.size()) {
|
if (last_string_starting_with_character.length() == buffer.size()) {
|
||||||
|
|
|
@ -66,4 +66,12 @@ BENCHMARK_CASE(load_4chan_catalog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(json_empty_string)
|
||||||
|
{
|
||||||
|
auto json = JsonValue::from_string("\"\"");
|
||||||
|
EXPECT_EQ(json.type(), JsonValue::Type::String);
|
||||||
|
EXPECT_EQ(json.as_string().is_null(), false);
|
||||||
|
EXPECT_EQ(json.as_string().is_empty(), true);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_MAIN(JSON)
|
TEST_MAIN(JSON)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue