json-path / JsonPath

Java JsonPath implementation
Apache License 2.0
8.92k stars 1.65k forks source link

expressions in nested arrays not working #782

Open scottbpennell opened 2 years ago

scottbpennell commented 2 years ago

Hello, I have a simple example of nested arrays and an expression demonstrating the issue. If arrays are not nested (it is the outer-most array) the same type of expression will work.

SAMPLE JSON { "food": [ { "appetizers": [ { "items": [ { "name": "Bruschetta", "price": "5.99" }, { "name": "Calamari", "price": "8.99" } ], "type": [ "Italian" ] } ] } ] } SAMPLE JsonPath $.food[0].appetizers[?(@.type=='Italian')].items[*].price

ACTUAL RESULT `[

]`

EXPECTED RESULT [ "5.99", "8.99" ]

This is the part that is not working in the nested array: ?(@.type=='Italian')

I discovered it in an early version but tried it with 2.6.0 with the same incorrect results

BugMaker-Boyan commented 2 years ago

I try this JsonPath, it works well. $.food[0].appetizers[?(@.type==['Italian'])].items[*].price