diff --git a/AK/JsonParser.cpp b/AK/JsonParser.cpp index 2d104af2678..54fdbe4888b 100644 --- a/AK/JsonParser.cpp +++ b/AK/JsonParser.cpp @@ -1,7 +1,6 @@ #include #include #include -#include namespace AK { @@ -34,10 +33,10 @@ void JsonParser::consume_while(C condition) template String JsonParser::extract_while(C condition) { - StringBuilder builder; + Vector buffer; while (condition(peek())) - builder.append(consume()); - return builder.to_string(); + buffer.append(consume()); + return String::copy(buffer); }; void JsonParser::consume_whitespace() @@ -54,13 +53,13 @@ void JsonParser::consume_specific(char expected_ch) String JsonParser::consume_quoted_string() { consume_specific('"'); - StringBuilder builder; + Vector buffer; for (;;) { char ch = peek(); if (ch == '"') break; if (ch != '\\') { - builder.append(consume()); + buffer.append(consume()); continue; } consume(); @@ -68,16 +67,16 @@ String JsonParser::consume_quoted_string() switch (escaped_ch) { case 'n': case 'r': - builder.append('\n'); + buffer.append('\n'); break; case 't': - builder.append('\t'); + buffer.append('\t'); break; case 'b': - builder.append('\b'); + buffer.append('\b'); break; case 'f': - builder.append('\f'); + buffer.append('\f'); break; case 'u': consume(); @@ -85,15 +84,15 @@ String JsonParser::consume_quoted_string() consume(); consume(); // FIXME: This is obviously not correct, but we don't have non-ASCII support so meh. - builder.append("?"); + buffer.append('?'); break; default: - builder.append(escaped_ch); + buffer.append(escaped_ch); break; } } consume_specific('"'); - return builder.to_string(); + return String::copy(buffer); } JsonValue JsonParser::parse_object()