Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Selecting properties containing a square bracket seems to be impossible #225

Copy link
Copy link
@baltpeter

Description

@baltpeter
Issue body actions

Describe the bug

As far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket ([]) in their name.

Code sample or steps to reproduce

Given the following JSON object:

{
  "abc": 2,
  "cd[DataLayer]": 1
}

I want to select the cd[DataLayer] property. These are the expressions I have tried (unsuccessfully):

$["cd[DataLayer]"]
$['cd[DataLayer]']
$.cd[DataLayer]
$.cd`[DataLayer]
$.cd`[DataLayer`]
$['`cd[DataLayer]']
$['cd`[DataLayer]']
$['cd`[DataLayer]`']
$[?(@.property == 'cd[DataLayer]')]
$.cd\[DataLayer\]
$.cd.DataLayer
$[`cd[DataLayer]]
$[cd[DataLayer]]

Console error or logs

No errors for any of the expressions listed above, but they all return an empty result ([]).

Expected behavior

I would expect there to be some expression that can select the cd[DataLayer] property.

As per the json-path-comparison project, $[']'] should return [42] for the input {"]": 42}, which fails in jsonpath-plus: https://cburgmer.github.io/json-path-comparison/results/bracket_notation_with_quoted_closing_bracket_literal.html#JavaScript_jsonpath-plus

Expected result

[
  1
]

Environment (IMPORTANT)

  • Locally using JSONPath-Plus version: 7.2.0
  • And on the demo page

Desktop

  • Firefox 132.0b5 on Ubuntu 24.04.1 LTS
  • Node v20.7.0
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.