Skip to content

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

@niaomingjian

Description

@niaomingjian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions