jslt icon indicating copy to clipboard operation
jslt copied to clipboard

Struggling with Queries

Open mfreeman-xtivia opened this issue 3 years ago • 1 comments

Given some input JSON like:

{"foo" : [
  {"name": "Smith", "age": 22},
  {"name": "Jones", "age": 30},
  {"name": "Doe", "age": 35}
]}

what is the JSLT expression that one would use to extract age "where name==Jones"?

mfreeman-xtivia avatar Jul 25 '21 15:07 mfreeman-xtivia

That's it.

let ageJones = array([for(.foo).age if(.name=="Jones")])[0]

{ "AgeJones" : $ageJones }

contatolucascosta avatar Jul 27 '21 16:07 contatolucascosta