vtrushin / json-to-ast

JSON AST parser
MIT License
237 stars 36 forks source link

Identifiers are over-escaped #17

Closed dvdsgl closed 7 years ago

dvdsgl commented 7 years ago

The property x" is represented in the AST as x\":

{ "x\"": 0 }

becomes:

{
  "type": "object",
  "children": [
    {
      "type": "property",
      "key": {
        "type": "identifier",
        "value": "x\\\"",
      },
  ...
}

Try this to verify:

> let sample = JSON.stringify({ 'x"': 0 })
> JSON.parse(sample)
{ 'x"': 0 }
> parse(sample).children[0].key.value
'x\\"'
vtrushin commented 7 years ago

@dvdsgl, is it correct now?