Open tunnckoCore opened 8 years ago
@TODO: FIX IT (separate the other types)
property
node.key.type
is always string
, because here {"a": 1}
the foo
is string, it cant be another.position
is constructed by key.position.start
and value.position.end
.position.start.offset
=== key.position.start.offset
.position.end.offset
=== value.position.end.offset
key.type
and value.type
cant be item
or property
types.contents
is always an array with length of 2.contents[0]
is always the key
type.contents[1]
is always the value
type.contents[0].contents
is always a string - json dont have support for other (key
type).contents[0].contents
CANNOT BE an array.contents[1].contents
CAN BE an array, can be anything (value
type)item
node.key.type
is always number
- it is the value
s index in the array.key.position
is always equal to .value.position
.contents[0].position
(the key) === .contents[1].position
(the value) - same as above.position
is always equal to key.position
, value.position
and above ^key.type
and value.type
cant be item
or property
types.contents
is always an array with length of 2.contents[0]
is always the key
type.contents[1]
is always the value
type.contents[0].contents
is always an number - the index (key
type).contents[0].contents
CANNOT BE an array.contents[1].contents
CAN BE an array, can be anything (value
type)array
node.contents
is always an array of objects - array of item
nodes.position
is obvious - from [
to ]
.position
contains line
, column
, offset
object
node.contents
is always an array of objects - array of property
nodes.position
is obvious - from {
to }
.position
contains line
, column
, offset
All other type
s (except that in item.contents
and property.contents
) are valid JavaScript types, based on kind-of lib (pretty fast)
So, 4 "major" types, 2 "minor" and all others are JavaScript types ("patch").
JSON AST
Pretty naive - first draft, it may have changes - it depends on if it is okey for programmatically usage. It is based on original/default JavaScript's
JSON.parse
method and little patch toreviver
idea (3 lines btw).