Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSONPath Expression with deep filter

Tags:

json

jsonpath

Given the following JSON Array

[
 {
  "id":1, 
  "list":[
    {"id":1,"type":{"ref":1,"tema":3}},
    {"id":2,"type":{"ref":1,"tema":6}}
  ]
 },...
]

Using a jsonPath expression, how can I get all the list elements with type.ref==1? I could not find a filter with 2 levels in all the examples I found with Google.

like image 802
J.M. Kenny Avatar asked Oct 27 '25 10:10

J.M. Kenny


1 Answers

I think this

$..list[?(@.type.ref == 1)]

or that

$..list..type[?(@.ref == 1)]

should do.

like image 93
stefankmitph Avatar answered Oct 30 '25 00:10

stefankmitph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!