jmespath / jmespath/jmespath.site
quoted-string grammar seems inconsistent with official parser behavior for empty string
- Dominant language
- Makefile
- Stars
- 61
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
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:
```ebnf
quoted-string = quote 1*(unescaped-char / escaped-char) quote
```
This 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/](https://jmespath.org/)) allows empty strings as object keys.
For example, given the following JSON input:
```json
{
"": 123
}
```
The expression:
```jmespath
""
```
correctly evaluates to:
```json
123
```
This 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:
```ebnf
quoted-string = quote *(unescaped-char / escaped-char) quote
```
This 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.