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:
| Name | Plan | |
|---|---|---|
| Alice | alice@acme.com | Pro |
| Bob | bob@startup.io | Free |
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: address → city → "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:
- What's the user's email?
- What's their plan?
- How many seats does their company have?
Answers:
user.email→"alice@acme.com"user.plan→"Pro"user.company.seats→25
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.