Skip to content

Path not found when square Brackets inside of Path String #167

Open
@Hugo2128

Description

Describe the bug

Using a string with square brackets inside as Path returns undefind even if the Path is there.

Code sample or steps to reproduce

Example:

{
    "firstName": "John",
    "lastName": "doe",
    "age": 26,
    "address": {
        "streetAddress": "naist street",
        "city": "Nara",
        "postalCode": "630-0192"
    },
    "phoneNumbers [1]": [
        {
            "type": "iPhone",
            "number": "0123-4567-8888"
        },
        {
            "type": "home",
            "number": "0123-4567-8910"
        }
    ]
}

Now i want to get "phoneNumbers [1]" with

path: $..['phoneNumbers [1]'] or
path: $..'phoneNumbers [1]' or
path: $..phoneNumbers [1]

returns No Match

Expected result

[
  [
    {
      "type": "iPhone",
      "number": "0123-4567-8888"
    },
    {
      "type": "home",
      "number": "0123-4567-8910"
    }
  ] 
]

Environment (IMPORTANT)

  • JSONPath-Plus version: 6.0.1

Desktop**

  • Tested on OS: MacOS, Ubuntu 22.04
  • Firefox version 100.0.2 64-bit

Additional context

When removing the square brackets everything works fine even when replacing them curly braces or parentheses

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions