jsonpath-plus prblem with key that start with @ character

372 views Asked by At

I am using jsonpath-plus 6.01. 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})

How can I access @ID value in this case?

2

There are 2 answers

1
Delta George On

This works in http://jsonpath.herokuapp.com/

$.Request.Vehicle['@ID']
0
gregsdennis On

This definitely seems like a bug in the implementation. You're correct in that both of those should work.

I would suggest opening an issue with the implementation so that they can fix it.