Article / Data & Structure ± 4 MIN READ
JSON: when data has structure
Read name–value pairs, lists, and the difference between text and numbers.
A message programs can read
Imagine sending a reading list to another program. Free-form sentences are easy for people to understand, but programs need explicit rules. JSON provides a text format with a structure many languages recognize.
Its name comes from JavaScript, but its use extends beyond that language. JSON stores data, rather than commands to execute.
{
"title": "Web Basics",
"lessons": 5,
"completed": false,
"topics": ["web", "data"]
}Names, values, and lists
Curly braces wrap an object: name–value pairs. In the example, title is a name and ‘Web Basics’ is its value. Names are double-quoted strings. A colon separates each name from its value; commas separate pairs.
Square brackets wrap an array, an ordered sequence of values. Order matters: a sequence of learning steps is read by position. By contrast, avoid making a program depend on object member order.
Text is different from a number
String is text. The values 5 and ‘5’ have different types despite looking similar. In the example, lessons is a number, completed is a boolean, and topics is an array. JSON also has null for an explicitly empty value.
JSON syntax is strict. Names and text use double quotes, and the last member has no trailing comma. Comments are not part of standard JSON. A JavaScript object snippet is not automatically valid JSON.
Start by reading, rather than memorizing
Read the example like a catalog card: what is its title, how many lessons does it contain, is it completed, and which topics appear? You do not need to execute this data to understand it.
If the structure is confusing, find matching brackets first. Then read each name and identify its value’s type. This habit helps when you encounter API responses or configuration files.
TRY TO UNDERSTAND
Skip to content