JMESPath

{
  "people": [
    {"first": "James", "last": "d"},
    {"first": "Jacob", "last": "e"},
    {"first": "Jayden", "last": "f"},
    {"missing": "different"}
  ],
  "foo": {"bar": "baz"}
}

Searching with the expression

capture:
  jmes: 'people[:2].first'
  as: [ name1, name2 ]

captures the values

[
  "James",
  "Jacob"
]

as the variables name1 and name1.