-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Title
Grammar for quoted-string excludes empty string, but official parser allows ""
Description
In the JMESPath documentation, the grammar for quoted-string is currently defined as:
quoted-string = quote 1*(unescaped-char / escaped-char) quoteThis definition requires at least one character between the quotes, which formally excludes the empty string "".
However, this appears to be inconsistent with the actual behavior of the official JMESPath parser.
Actual Behavior
The official JMESPath implementation (including the online interpreter on https://jmespath.org/) allows empty strings as object keys.
For example, given the following JSON input:
{
"": 123
}The expression:
""
correctly evaluates to:
123This behavior is also consistent with JSON semantics, where object keys may be empty strings.
Expected / Documented Behavior
Based on the current grammar definition using 1*, the empty string "" would not be considered a valid quoted-string, which does not reflect the actual parser behavior.
Suggested Change
To better align the documented grammar with the existing behavior and JSON string semantics, it may be more accurate to define quoted-string as:
quoted-string = quote *(unescaped-char / escaped-char) quoteThis allows zero or more characters between the quotes and explicitly includes the empty string "".
Notes
- This issue does not propose any change to parser behavior.
- The suggestion is intended purely as a documentation / grammar clarification to reflect existing, widely implemented behavior.