jmespath / jmespath.py

JMESPath is a query language for JSON.
http://jmespath.org
MIT License
2.19k stars 181 forks source link

It doesn't look like jmespath can provide context for a query result #214

Open kintarowins opened 3 years ago

kintarowins commented 3 years ago

for example I would like to query people[?first=='James'].last with this json

{
  "people": [
    {"first": "James", "last": "d"},
    {"first": "Jacob", "last": "e"},
    {"first": "Jayden", "last": "f"},
    {"missing": "different"}
  ],
}

and instead of just getting the result d, I'd like to also get the full path to it .e.g people[0].last

springcomp commented 2 years ago

The upcoming let() function in JMESPath Community is specifically designed to achieve this scenario.

kintarowins commented 2 years ago

Thanks @springcomp. That's cool although I still can't grasp the example given in the preview documentation. My use-case is straight-forward, given a search expression, return the full path to the result.

springcomp commented 2 years ago

Oh maybe I misconstrued your example. Unfortunately no, that's not something that would be easily done in the general case I'm afraid. Seems similar to this request if I'm not mistaken?