tc39 / proposal-json-parse-with-source

Proposal for extending JSON.parse to expose input source text.
https://tc39.github.io/proposal-json-parse-with-source
MIT License
213 stars 9 forks source link

Advance to stage 3 #14

Closed gibson042 closed 2 years ago

gibson042 commented 4 years ago

Criteria taken from the TC39 process document minus those from previous stages:

  • [x] Complete spec text

https://github.com/tc39/proposal-json-parse-with-source/blob/master/spec.html https://tc39.es/proposal-json-parse-with-source/

  • [x] Designated reviewers have signed off on the current spec text
  • [ ] The ECMAScript editor has signed off on the current spec text
gibson042 commented 2 years ago

@michaelficarra @waldemarhorwat I believe this is ready for review: https://tc39.es/proposal-json-parse-with-source/

michaelficarra commented 2 years ago

@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?

gibson042 commented 2 years ago

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.