mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb/Infra: Port serialize_javascript_value_to_json_string() to String
This commit is contained in:
parent
93ed1b59c8
commit
7800276c0f
Notes:
sideshowbarker
2024-07-17 03:14:39 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/7800276c0f Pull-request: https://github.com/SerenityOS/serenity/pull/17718
2 changed files with 6 additions and 5 deletions
|
@ -1,9 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -34,7 +35,7 @@ WebIDL::ExceptionOr<JS::Value> parse_json_bytes_to_javascript_value(JS::VM& vm,
|
|||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string
|
||||
WebIDL::ExceptionOr<DeprecatedString> serialize_javascript_value_to_json_string(JS::VM& vm, JS::Value value)
|
||||
WebIDL::ExceptionOr<String> serialize_javascript_value_to_json_string(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
|
@ -49,7 +50,7 @@ WebIDL::ExceptionOr<DeprecatedString> 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ namespace Web::Infra {
|
|||
|
||||
WebIDL::ExceptionOr<JS::Value> parse_json_string_to_javascript_value(JS::VM&, StringView);
|
||||
WebIDL::ExceptionOr<JS::Value> parse_json_bytes_to_javascript_value(JS::VM&, ReadonlyBytes);
|
||||
WebIDL::ExceptionOr<DeprecatedString> serialize_javascript_value_to_json_string(JS::VM&, JS::Value);
|
||||
WebIDL::ExceptionOr<String> serialize_javascript_value_to_json_string(JS::VM&, JS::Value);
|
||||
WebIDL::ExceptionOr<ByteBuffer> serialize_javascript_value_to_json_bytes(JS::VM&, JS::Value);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue