Step: Optional access: .foo?

Optional access: .foo?

Appending ? suppresses errors from an access that doesn't apply, producing nothing instead of failing. On a missing object key you simply get null; ? matters most when the value might not be an object at all.

.address?.zip?     # never throws, even if .address is absent

Why it matters: it's the jq equivalent of optional chaining (?.) — essential when iterating over heterogeneous records.

Your turn: safely read a middleName that isn't there (expected output is null).

Input:
{
  "firstName": "Charles",
  "lastName": "Doe"
}
Expected:
null
Step 5 of 27