Step: Bracket keys: .["foo"]

Bracket keys: .["foo"]

.["foo"] is the general form of .foo. Use it when a key isn't a plain identifier — e.g. it contains a dash, space, or dot.

.["postal-code"]      # .postal-code would be parsed as subtraction!

Why it matters: .postal-code is read by jq as ".postal minus code". Real-world JSON keys (content-type, user id) force the bracket form all the time.

Your turn: read the postal-code from location.

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