Introduction
JSON, JavaScript Object Notation, is a lightweight text format for representing structured data, built from a small set of building blocks: objects (key-value pairs wrapped in curly braces), arrays (ordered lists wrapped in square brackets), strings, numbers, booleans, and null. Despite its name referencing JavaScript, JSON is language-independent; nearly every programming language has a library to parse JSON text into its own native data structures and to serialize its own data back into JSON text.
Cricket analogy: A scorecard format that any cricket board in the world can read regardless of which country produced it, built from a small set of consistent fields like runs, overs, and wickets, mirrors how JSON is a language-independent text format that nearly any programming language can parse the same way.
Explanation
A JSON object is an unordered set of key-value pairs, written as { "key": value, ... }, where keys are always strings in double quotes and values can be any JSON type, including another object or array nested inside. A JSON array is an ordered list of values written as [ value, value, ... ], and the values inside it don't have to be the same type, though in practice they usually are for consistency.
Cricket analogy: A player record written as key-value pairs like { "name": "Player A", "team": "Team X" } is a JSON object where keys are always quoted strings, and a batting-order array like ["Player A", "Player B", "Player C"] is a JSON array, an ordered list where position matters, unlike the unordered object.
JSON's primitive value types are strings (in double quotes, never single quotes), numbers (no quotes, and no distinction between integer and floating-point at the format level), booleans (the literal values true or false, lowercase and unquoted), and null (the literal value null, representing the deliberate absence of a value). Unlike some formats, JSON has no support for comments, dates as a native type, or trailing commas after the last item in an object or array — including a trailing comma is a syntax error that will cause a strict parser to reject the entire document.
Cricket analogy: A scorecard field like "venue": "Lord's" uses a quoted string, "runs": 87 uses an unquoted number, "isOut": true uses a lowercase boolean, and "dismissalType": null marks a not-out player deliberately having no dismissal value, and leaving a stray comma after the last field would make a strict scorecard parser reject the whole file, mirroring JSON's exact syntax rules.
{
"name": "Ada Lovelace",
"age": 36,
"isActive": true,
"nickname": null,
"skills": ["mathematics", "programming"],
"address": {
"city": "London",
"country": "UK"
}
}
Example
This example shows a nested JSON object: the top-level object has a string ("name"), a number ("age"), a boolean ("isActive"), a null ("nickname"), an array of strings ("skills"), and a nested object ("address") which itself has two string fields. A JSON parser in any language would turn this text into that language's native equivalents — for example, in Python it becomes a dict with a nested dict and a list, and in JavaScript it becomes an object with a nested object and an array.
Cricket analogy: A player-profile JSON with a string name, a number age, a boolean isActive, a null nickname, an array of skills, and a nested address object would be parsed by any team's software into its own native structures, a Python dict with a nested dict and list, or a JavaScript object with a nested object and array, exactly as the example shows.
Analysis
JSON has no native date type: dates are conventionally represented as strings, most often in ISO 8601 format like "2026-07-26", and it is up to each application to parse that string into an actual date object — the format itself doesn't enforce or guarantee this.
Key Takeaways
- JSON represents structured data using objects (key-value pairs), arrays (ordered lists), strings, numbers, booleans, and null.
- JSON is language-independent despite its name; nearly every language can parse JSON text and serialize its own data into JSON.
- Object keys are always double-quoted strings; values can be any JSON type, including nested objects or arrays.
- JSON has no comments, no native date type, and does not allow trailing commas after the last element.
- A JSON parser converts the text into a language's native data structures, such as a Python dict/list or a JavaScript object/array.
Practice what you learned
1. What are the two structural building blocks of JSON?
2. In JSON, how must object keys be written?
3. Which of the following is NOT a valid JSON primitive type?
4. What happens if a JSON document includes a trailing comma after the last item in an array?
5. Why is JSON described as language-independent despite its name referencing JavaScript?
Was this page helpful?
You May Also Like
What Is an API
An overview of application programming interfaces, how they define a contract between systems, and how REST APIs use HTTP.
What Is OOP
An introduction to object-oriented programming, covering classes, objects, encapsulation, inheritance, and polymorphism.
Reading Documentation
A practical guide to reading technical documentation efficiently, covering reference docs, signatures, examples, and changelogs.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics