Open
Description
According to the included types lhs
in ExprNode
should be of type ExprNode
itself.
Meanwhile:
const JSONATA_STRING = `{"x": y}`;
const expression = jsonata(JSONATA_STRING);
console.log(JSON.stringify(expression.ast()));
resolves to:
{
"type":"unary",
"value":"{",
"position":1,
"lhs":[
[
{
"value":"x",
"type":"string",
"position":4
},
{
"type":"path",
"steps":[
{
"value":"y",
"type":"name",
"position":7
}
]
}
]
]
}
As you can see, lhs is an array here.
Incorrect types make it really hard to traverse the whole expression.ast()
tree without checking 2k+ lines source code files, which makes the developer experience not that fun.
Also I didn't really go that deep into the source code, but something like this seems more intuitive at the first glance and is coherent with the provided types:
{
"type":"unary",
"value":"{",
"position":1,
"steps?/stages?":[
{
"type":"binary",
"value":":",
"position":3,
"lhs":{
"value":"x",
"type":"string",
"position":4
},
"rhs":{
"type":"path",
"steps":[
{
"value":"y",
"type":"name",
"position":7
}
]
}
}
]
}
Metadata
Metadata
Assignees
Labels
No labels