diff --git a/AK/JsonParser.cpp b/AK/JsonParser.cpp index 983d99fbd94..41b3c7a2b1e 100644 --- a/AK/JsonParser.cpp +++ b/AK/JsonParser.cpp @@ -101,7 +101,7 @@ String JsonParser::consume_quoted_string() consume_specific('"'); if (buffer.is_empty()) - return {}; + return String::empty(); auto& last_string_starting_with_character = m_last_string_starting_with_character[(int)buffer.first()]; if (last_string_starting_with_character.length() == buffer.size()) { diff --git a/AK/Tests/TestJSON.cpp b/AK/Tests/TestJSON.cpp index 4d90e8a8bb5..3f4279ca306 100644 --- a/AK/Tests/TestJSON.cpp +++ b/AK/Tests/TestJSON.cpp @@ -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)