JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
963 stars 169 forks source link

Problem with key that start with @ character #166

Closed lOdwrot closed 2 years ago

lOdwrot commented 2 years ago

Describe the bug

When trying

Code sample or steps to reproduce

I have following JSON:

{
  "Request": {
    "@Domain": "SomeDomain",
    "Vehicle": {
      "@ID": "E11XPD"
    }
  }
}

I can execute following jsonpath expression:

$.Request['@Domain']

When I want to acces ID by expression:

$.Request.Vehicle['@ID']

I have following error: "Unknown value type".

I am using library this way:

import { JSONPath } from 'jsonpath-plus';
...
JSONPath({path: pattern, json: resultJson})

Console error or logs

Unknown value type

Expected behavior

Function will return value under proper key.

Expected result

I will have a value of node under @ID key (in this case E11XPD)

Environment (IMPORTANT)

Desktop**

brettz9 commented 2 years ago

For jsonpath-plus, you need to escape the at-sign with a backtick `. That should resolve, so closing, though feel free to comment further.