Step: Capstone: put it together

Capstone: put it together

Time to combine object construction, computed values, nested access, and a built-in.

Build an object with:

  • name: "Doe, Charles" (last, first)
  • city: the person's city
  • hobbyCount: how many hobbies they have

Docs for everything you've learned: the official jq manual.

Input:
{
  "firstName": "Charles",
  "lastName": "Doe",
  "age": 41,
  "location": {
    "city": "San Francisco",
    "postal-code": "94103"
  },
  "hobbies": [
    "chess",
    "netflix"
  ],
  "pets": [
    {
      "name": "Bear",
      "kind": "dog"
    },
    {
      "name": "Jerry",
      "kind": "cat"
    }
  ]
}
Expected:
{
  "name": "Doe, Charles",
  "city": "San Francisco",
  "hobbyCount": 2
}
Step 27 of 27