From 2f631f7dc0d325869d8f4ed890cc98bcfcd71fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Thu, 27 Jan 2022 13:01:10 +0100 Subject: [PATCH] AK: Allow constructing a JsonValue from a StringView explicitly The next commit will destroy overload detection otherwise, so let's add this constructor. Currently, the same work is already done implicitly through the implicit `String(StringView)` constructor. --- AK/JsonValue.cpp | 6 ++++++ AK/JsonValue.h | 1 + 2 files changed, 7 insertions(+) diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index a1bc94ce554..b29cf1a9b08 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifndef KERNEL # include @@ -184,6 +185,11 @@ JsonValue::JsonValue(const String& value) } } +JsonValue::JsonValue(StringView value) + : JsonValue(value.to_string()) +{ +} + JsonValue::JsonValue(const JsonObject& value) : m_type(Type::Object) { diff --git a/AK/JsonValue.h b/AK/JsonValue.h index 8f478b77930..2b0b0497da2 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -54,6 +54,7 @@ public: JsonValue(bool); JsonValue(const char*); JsonValue(const String&); + JsonValue(StringView); JsonValue(const JsonArray&); JsonValue(const JsonObject&);