Gathering the values from the keys in a list with JMESPath

30 Views Asked by At

Given {"a": "foo", "b": "bar", "c": "baz"} and ["b", "c"], how to get ["bar", "baz"]?

I tried map(*.@, ["b", "c"]) but it doesn't work.

1

There are 1 best solutions below

2
β.εηοιτ.βε On BEST ANSWER

The expression you are looking for is literally your list of field.

The query:

["b", "c"]

note: which could also be expressed [b, c]

Would give you:

[
  "bar",
  "baz"
]