/* * Copyright (c) 2022-2023, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::Infra { using JSONBaseValue = Variant; using JSONValue = Variant>; struct JSONObject { OrderedHashMap> value; }; using JSONTopLevel = Variant; WebIDL::ExceptionOr parse_json_string_to_javascript_value(JS::Realm&, StringView); WebIDL::ExceptionOr parse_json_bytes_to_javascript_value(JS::Realm&, ReadonlyBytes); WebIDL::ExceptionOr serialize_javascript_value_to_json_string(JS::VM&, JS::Value); WebIDL::ExceptionOr serialize_javascript_value_to_json_bytes(JS::VM&, JS::Value); String serialize_an_infra_value_to_a_json_string(JS::Realm&, JSONTopLevel const&); ByteBuffer serialize_an_infra_value_to_json_bytes(JS::Realm&, JSONTopLevel const&); }