h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
572 stars 85 forks source link

support for JSON/SQL style filters? #84

Open bdeboe opened 3 years ago

bdeboe commented 3 years ago

JSON/SQL implementations such as PostgreSQL and Oracle seem to use a slightly different style of filters than what is supported by this library:

select * from jsonb_path_query('{"a":[1,2,3,4,5]}', '$.a[*] ? (@ >= 2 && @ <= 4)') -- Postgres

select * from JSON_QUERY('...', '$.friends[3]?(@.addresses.city == "San Francisco")') -- Oracle

Whereas those JSONPath expressions would have to be rewritten to $.a[? (@ >= 2 && @ <= 4)] and $.friends[3, ?(@.addresses.city == "San Francisco")], respectively to work for this library. Has this request come up before? Anyone knows a library that follows this approach?

Note that the latter example combines an index with a filter as requested in #50, for which the "SQL notation" might actually be a helpful approach.