From 7800276c0f22ca587b4720122ab5b601aba815f1 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 4 Mar 2023 21:46:04 +0000 Subject: [PATCH] LibWeb/Infra: Port serialize_javascript_value_to_json_string() to String --- Userland/Libraries/LibWeb/Infra/JSON.cpp | 7 ++++--- Userland/Libraries/LibWeb/Infra/JSON.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/Infra/JSON.cpp b/Userland/Libraries/LibWeb/Infra/JSON.cpp index 05d73c5dfc4..bf00474d73d 100644 --- a/Userland/Libraries/LibWeb/Infra/JSON.cpp +++ b/Userland/Libraries/LibWeb/Infra/JSON.cpp @@ -1,9 +1,10 @@ /* - * Copyright (c) 2022, Linus Groh + * Copyright (c) 2022-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -34,7 +35,7 @@ WebIDL::ExceptionOr parse_json_bytes_to_javascript_value(JS::VM& vm, } // https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string -WebIDL::ExceptionOr serialize_javascript_value_to_json_string(JS::VM& vm, JS::Value value) +WebIDL::ExceptionOr serialize_javascript_value_to_json_string(JS::VM& vm, JS::Value value) { auto& realm = *vm.current_realm(); @@ -49,7 +50,7 @@ WebIDL::ExceptionOr serialize_javascript_value_to_json_string( VERIFY(result.is_string()); // 4. Return result. - return TRY(result.as_string().deprecated_string()); + return TRY(result.as_string().utf8_string()); } // https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-json-bytes diff --git a/Userland/Libraries/LibWeb/Infra/JSON.h b/Userland/Libraries/LibWeb/Infra/JSON.h index c24ac27cac2..8777679b535 100644 --- a/Userland/Libraries/LibWeb/Infra/JSON.h +++ b/Userland/Libraries/LibWeb/Infra/JSON.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Linus Groh + * Copyright (c) 2022-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -14,7 +14,7 @@ namespace Web::Infra { WebIDL::ExceptionOr parse_json_string_to_javascript_value(JS::VM&, StringView); WebIDL::ExceptionOr parse_json_bytes_to_javascript_value(JS::VM&, ReadonlyBytes); -WebIDL::ExceptionOr serialize_javascript_value_to_json_string(JS::VM&, JS::Value); +WebIDL::ExceptionOr serialize_javascript_value_to_json_string(JS::VM&, JS::Value); WebIDL::ExceptionOr serialize_javascript_value_to_json_bytes(JS::VM&, JS::Value); }