Step: Recursive descent: ..

Recursive descent: ..

.. walks every value in the document, at any depth — jq's equivalent of XPath //. Combine it with select or optional access to find fields wherever they're buried.

.. | .id?           # every "id" anywhere in the tree

Pitfall: .. visits containers too, so you'll see nulls from objects that lack the key — filter them out with select(. != null).

Your turn: collect every kind value found anywhere in the document (dogs and cats included).

Input:
{
  "firstName": "Charles",
  "lastName": "Doe",
  "pets": [
    {
      "name": "Bear",
      "kind": "dog"
    },
    {
      "name": "Jerry",
      "kind": "cat"
    }
  ]
}
Expected:
[
  "dog",
  "cat"
]
Step 26 of 27