-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
A very useful feature of XSLT is to supports recursive tree traversal using XPath.
I believe such a feature would be a great addition to JMESPath.
I have drafted a very ugly working prototype for what could be a new descendant-expression
Specification
A new descendant-expression will be added as an alternative to the expression grammar rule:
descendant = ".." identifier
descendant-expression = ( expression ) 1*( descendant )
expression =/ descendant-expressionA descendant-expression is a projection that returns an array with all the elements of the JSON input with the specified name.
Examples
Given the following JSON input:
{
"name": "first",
"top": { "name": "second" },
"nested": {
"name": [
1, "string", false,
{ "name": "third" }
]
}
}The following expressions are possible:
| Expression | Result |
|---|---|
..name |
["first","second",[1,"string",false,{"name":"third"}],"third"] |
..name.length(@) |
[5, 6, 4, 5] |
..name..name |
["third"] |
Compliance Tests
This JEP standardizes a syntax that was formely not valid. For this reason, one of the syntax.json compliance tests must be changed or removed altogether:
{
"expression": ".foo",
"error": "syntax"
},
{
"expression": "foo..bar",
- "error": "syntax"
+ "result": null
},A new file descendant.json will be added to the compliance test suite.
MikeAtEffectual, MrBones757, mauvilsa, anentropic, bc3tech and 4 more
Metadata
Metadata
Assignees
Labels
No labels