jmespath

Gathering the values from the keys in a list with JMESPath


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.


Solution

  • 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"
    ]