Data types
The six types of JSON
You've already seen all of these in action. Now let's name them properly, because when you're reading API docs or talking to an engineer, it helps to use the right words.
JSON has exactly six types of values. That's it. Every API response in the world is built from these six building blocks.
Strings
Text, wrapped in double quotes. Always double quotes. Single quotes don't work in JSON.
"alice@acme.com"
This is the most common type. Names, emails, IDs, dates, statuses, URLs: all strings. If it has quotes around it, it's a string.
One thing to watch out for: "true" (with quotes) is a string, not a boolean. And "42" (with quotes) is a string, not a number. The quotes make all the difference.
Numbers
Just numbers. No quotes, no currency symbol, no formatting.
49.99
2000
You saw in lesson 2 that Stripe uses 2000 for $20.00. That's a number. If you see "2000" with quotes, that's a string. Same digits, very different meaning for the code consuming it.
Numbers can be integers (42) or decimals (49.99). There's no distinction in JSON. They're all just "numbers."
Booleans
true or false. No quotes.
true
Think of these as on/off switches. You'll see them for:
"is_active": true: is this account active?"email_verified": false: has the user confirmed their email?"auto_renew": true: will the subscription renew automatically?
When you spot a boolean in an API response, ask yourself: what does "false" mean for the user experience? That's a product question.
Null
null. No quotes. Means "no value". The field exists but is empty.
null
Not the same as "" (empty string), not the same as 0, not the same as false. It literally means: nothing here.
You saw "referral_code": null in lesson 2. The field is there, the API acknowledges it, but this particular user has no referral code.
As a PM, null usually means "optional field, not filled in." When you're writing a spec, it's worth asking: what should the UI show when this field is null? A dash? "N/A"? Nothing at all?
Objects
Curly braces {}. A collection of key-value pairs.
{
"name": "Acme Corp",
"industry": "SaaS",
"employee_count": 150
}
You know these well by now. Objects group related info together. They can be nested (an object inside an object) as deep as needed.
Arrays
Square brackets []. An ordered list of things.
["read", "write", "export"]
Arrays can contain any type: strings, numbers, objects, even other arrays. The most common pattern you'll see is an array of objects:
[
{ "id": 1, "name": "Free", "price": 0 },
{ "id": 2, "name": "Pro", "price": 2900 },
{ "id": 3, "name": "Enterprise", "price": null }
]
Notice that last one. "price": null. Enterprise pricing is custom, so there's no price. Types mix together all the time in real API responses.
That's JSON
Six types. Two brackets. You now have everything you need to read any API response on the planet.
In the next chapter, we'll look at what an API actually is: how requests and responses work, and how your product uses them to talk to other services.