Closed gibson042 closed 2 years ago
@michaelficarra @waldemarhorwat I believe this is ready for review: https://tc39.es/proposal-json-parse-with-source/
@gibson042 Spec text LGTM, though I'd prefer if we could use ParseText
in JSON.rawJSON
steps 2/3. Is there a reason we don't mimic the use of ParseText
in JSON.parse
?
JSON.rawJSON
does mirror JSON.parse
; step 3 of the latter matches step 2 of the former with an extra constraint. It doesn't use ParseText because it has no use for a parse tree, but are you suggesting a refactor for perfect alignment of the first two steps?
1. Let _jsonString_ be ? ToString(_text_).
1. Parse StringToCodePoints(_jsonString_) as a JSON text as specified in ECMA-404. Throw a *SyntaxError* exception if it is not a valid JSON text as defined in that specification.
1. If _jsonString_ is the empty String, or if either the first or last code unit of jsonString is any of `{`, `[`, 0x0009 (CHARACTER TABULATION), 0x000A (LINE FEED), 0x000D (CARRIAGE RETURN), or 0x0020 (SPACE), throw a **SyntaxError** exception.
Criteria taken from the TC39 process document minus those from previous stages:
https://github.com/tc39/proposal-json-parse-with-source/blob/master/spec.html https://tc39.es/proposal-json-parse-with-source/