quoted-string grammar seems inconsistent with official parser behavior for empty string

Open Beginner friendly
#137 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
62/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Domain
documentation

Research direction

Locate the JMESPath documentation page containing the quoted-string EBNF and compare its 1* quantifier with the parser behavior described here. Update the grammar to allow zero or more characters, then verify that the rendered documentation includes the empty string case.

Written by the indexing model from the issue text.

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) 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/) allows empty strings as object keys.

For example, given the following JSON input:

{
  "": 123
}

The expression:

""

correctly evaluates to:

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:

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.
Dominant language
Makefile
Stars
61
Forks
61
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jmespath/jmespath.site

All issues in jmespath/jmespath.site

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.