Step: Build objects: {a, b}

Build objects: {a, b}

{ } builds objects. The shorthand {firstName, lastName} copies those keys straight from the input — like JavaScript's shorthand property names.

Why it matters: projecting a few fields out of a large record is one of jq's most common jobs (think trimming an API response).

Your turn: keep only firstName and lastName.

Input:
{
  "firstName": "Charles",
  "lastName": "Doe",
  "location": {
    "city": "San Francisco",
    "postal-code": "94103"
  }
}
Expected:
{
  "firstName": "Charles",
  "lastName": "Doe"
}
Step 12 of 27