besok / jsonpath-rust

Support for json-path in Rust
https://crates.io/crates/jsonpath-rust
MIT License
99 stars 26 forks source link

Use wildcard in conditional selection i.e. $..*[?(@.isbn)] instead of $..book[?(@.isbn)] #26

Closed oiwn closed 1 year ago

oiwn commented 1 year ago

I'm trying this in online json-path evaluators and both i tried working. Maybe i'm doing something wrong? Basically need to express the following: "select all nodes with child node X"

besok commented 1 year ago

Hi.
Thanks for raising this issue.

It is a bug in the parser. I will tackle it in a week or so.

Elements to reproduce:

Json ```json { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } }, "expensive": 10 } ```

path: $..*[?(@.isbn)].title

Expected result: [ "Moby Dick", "The Lord of the Rings"]


Where to look:

besok commented 1 year ago

Issue jsopath

oiwn commented 1 year ago

thank you!