Skip to content
KodeTrail

Camp 1 · Step 2 of 12

JSON: the language of documents

Objects, arrays, and values — learn to read and write the format the entire modern web speaks.

12 min+50 XP

Document databases store JSON (JavaScript Object Notation) — which happens to also be the format APIs speak, config files use, and this site's search index is stored in. Learning it pays rent everywhere.

An object

{
  "name": "Ada",
  "trail": "python",
  "streak": 7,
  "premium": false
}
  • Curly braces { } wrap an object
  • Each entry is a "key": value pair, comma-separated
  • Keys are always double-quoted strings

The six value types

TypeExample
string"Ada" (double quotes only!)
number7, 3.14, -2
booleantrue, false
nullnull — deliberately empty
array["boots", "map"]
object{ "lat": 46.5, "lon": 11.3 }

Arrays and objects nest — that's the superpower:

{
  "name": "Ada",
  "gear": ["boots", "compass"],
  "camp": { "name": "Base", "altitude": 1200 },
  "buddy": null
}

One document holds a whole shape — a profile, an order with its items, a lesson with its quizzes — no assembly from separate tables required.

The strict bits

JSON is fussier than JavaScript: double quotes only, no trailing commas, no comments. Every parser on Earth agrees on these rules — which is exactly why everything can talk to everything.

Checkpoint

Which of these is valid JSON?

Checkpoint

How would you represent a hiker's three badges in JSON?

What's next

Documents vs. tables, head to head — the same data modeled both ways.