Skip to content

Property names containing backslashes cannot be expressed in the syntax #203

Open

Description

@belfordzjeeves

Description

In jsonpath syntax (e.g. $["a\\b"]), there appears to be no way to express a property name that itself contains a backslash. Bracket-quoted segments are parsed with JSON.parse-style unescaping (or similar), so a literal backslash in the property name gets consumed as an escape introducer and there is no escape sequence that yields a literal backslash character in the resulting key.

Reproduction

A data object like { "a\\b": 1 } (key containing a literal backslash) cannot be addressed — any attempt to quote the segment (e.g. $["a\\b"], $['a\\\\b']) either unescapes to a different key or fails to parse to the intended literal key.

Expected

Some way to express a literal backslash in a bracket-quoted property name, e.g. $["a\\\\b"] resolving to the key a\b.

Context

Found while working on json-schema-tools/validator, where schemas may have properties whose names contain backslashes; those subschemas currently cannot be addressed at all.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions