Search code examples
jsonjsonpath

JSONPath Expression with deep filter


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.


Solution

  • I think this

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

    or that

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

    should do.