Compact syntax for multi-select-hash #19
-
Compact syntax for multi-select-hash
AbstractThis JEP proposes a grammar modification to support ES6-style compact MotivationConsider the following JSON document:
Let’s say we wanted to return a hash containing
Since This JEP supports this syntax to make JMESPath usage slightly less verbose. In addition, this JEP enables empty SpecificationThe multi-select-hash = "{" *( multi-select-hash-entry ) "}"
multi-select-hash-entry = identifier / keyval-expr
keyval-expr = identifier ":" expression Note that an empty
For consistency, an empty
Motivating ExampleWith these changes defined, the expression in the “Motivation” section can be written as:
Which evaluates to Compliance TestsThis JEP standardizes a syntax that was formely not valid. For this reason, one of the {
"comment": "Multi-select hash syntax",
"given": {
"type": "object"
},
"cases": [
{
- "comment": "Not a key-value pair",
+ "comment": "Valid single-key multi-select hash extraction",
"expression": "a.{foo}",
- "error": "syntax"
+ "result": null
}
]
} New tests will also be added to the RationaleThis JEP is inspired by an idea from Dan Vanderkam. History
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Should we standardize support for empty |
Beta Was this translation helpful? Give feedback.
-
Why not support multi-select-hash = "{" *( multi-select-hash-entry ) "}"
multi-select-hash-entry = identifier / keyval-expr |
Beta Was this translation helpful? Give feedback.
-
One more reason we may need to support this. When using combinations of the
Allowing |
Beta Was this translation helpful? Give feedback.
-
This looks good to me. |
Beta Was this translation helpful? Give feedback.
Should we standardize support for empty
multi-select-hash
expressions here?