From 26b62234cb427bf0561ab475957058e8d48d9f86 Mon Sep 17 00:00:00 2001 From: Halid Odat Date: Fri, 7 May 2021 22:57:07 +0200 Subject: [PATCH] Implement `JSON[ @@toStringTag ]` (#1224) --- boa/src/builtins/json/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/boa/src/builtins/json/mod.rs b/boa/src/builtins/json/mod.rs index b52de61ece..ab8f91984b 100644 --- a/boa/src/builtins/json/mod.rs +++ b/boa/src/builtins/json/mod.rs @@ -41,7 +41,12 @@ impl BuiltIn for Json { fn init(context: &mut Context) -> (&'static str, Value, Attribute) { let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let to_string_tag = context.well_known_symbols().to_string_tag_symbol(); + + let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; + let json_object = ObjectInitializer::new(context) + .property(to_string_tag, "JSON", attribute) .function(Self::parse, "parse", 2) .function(Self::stringify, "stringify", 3) .build();