Chapter 01 — JSON — the language APIs speak3 min read

Understanding JSON

So… what is JSON?

Let's start simple: JSON is a way to organize data. That's it.

"A way to organize data?" Yes. An Excel spreadsheet is a way to organize data. A CSV file too. JSON is the same idea, just a format that machines use to talk to each other.

The good news: if you can read an Excel table, you can already read JSON. Let's prove it right now.


A table you already know

Picture a user table in your favorite tool:

NameEmailPlan
Alicealice@acme.comPro
Bobbob@startup.ioFree

You can spot three things here:

  • The columns (Name, Email, Plan): the categories of info
  • The cells (Alice, alice@acme.com): the actual values
  • Each row: one complete user

Keep that in mind. We're about to see the exact same logic in JSON.


The same table, in JSON

{
  "users": [
    { "name": "Alice", "email": "alice@acme.com", "plan": "Pro" },
    { "name": "Bob", "email": "bob@startup.io", "plan": "Free" }
  ]
}

Same table, different format. Here's the mental translation:

  • { } → an object (= one row)
  • [ ] → a list (= all the rows)
  • "name": "Alice" → column + cell

That's it. You just read JSON.


Nested objects

Sometimes, a piece of info contains other pieces of info. For example, a user has an address, and an address has a street, a city, etc.

In Excel, you'd end up with awkward columns like Address.Street, Address.City. It works, but it's clunky.

In JSON, it's more natural. You put an object inside an object:

{
  "name": "Alice",
  "email": "alice@acme.com",
  "address": {
    "street": "12 Main St",
    "city": "Paris"
  }
}

address contains a sub-object with its own keys. To find Alice's city, you follow the path: addresscity"Paris".

No code needed. Just follow the structure.


Mini exercise: find the info

Here's a chunk of JSON that an API might send back:

{
  "user": {
    "id": 8421,
    "name": "Alice",
    "email": "alice@acme.com",
    "plan": "Pro",
    "company": {
      "name": "Acme Corp",
      "seats": 25
    }
  }
}

Try to answer before reading on:

  1. What's the user's email?
  2. What's their plan?
  3. How many seats does their company have?

Answers:

  1. user.email"alice@acme.com"
  2. user.plan"Pro"
  3. user.company.seats25

If you got those right, you can read JSON. Seriously, that's the skill.


Key takeaways

  • JSON = data organized as a tree (objects containing objects, lists, values)
  • { } = an object: think "one row" or "a group of info"
  • [ ] = a list: think "multiple rows"
  • You don't need to code. Just spot the keys and follow the structure.