Skip to content

Error thrown when using square brackets to access property at the root of the JSON #258

@settergren

Description

@settergren

Describe the bug

An exception is thrown when using square brackets to access properties at the root of an object.

Code sample

const data = {
  "@id": "test"
}

JSONPath({json: data, path: "$['@id']", wrap: false});

Console error or logs

TypeError: Unknown value type

Expected behavior

I should be able to select attributes at the root of an object that start with special characters such as "@id"

Expected result

In the example above I expect to get "test" as a result

Environment (IMPORTANT)

"jsonpath-plus": "^10.4.0",

Desktop**

  • Windows
  • Chrome 145.0.7632.118

Extra Info

This works when accessing a nested object (For example, "$.foo['@id']")

Metadata

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