Lesson 1 — Getting Started

Introduction to JSON

JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It has become the standard way applications exchange data over the web.

Why JSON Is Everywhere

JSON was derived from JavaScript's object literal syntax, but it is language-independent — nearly every programming language has built-in or library support for reading and writing it. Its combination of human readability and simple, predictable structure made it the default format for web APIs, configuration files, and data storage.

When your browser fetches data from a server without reloading the page — a live search suggestion, a social media feed, a weather widget — that data almost always arrives as JSON.

A First Look

A JSON document represents data as a set of key-value pairs and ordered lists, using a small, strict set of punctuation rules.

JSON — A simple object
{
  "name": "Lindiwe",
  "age": 27,
  "isStudent": true,
  "courses": ["HTML", "CSS", "JSON"]
}

Common Mistakes

  • Confusing JSON (a data format) with JavaScript (a programming language) — JSON is a subset of JavaScript's object syntax, but is used across virtually every language.
  • Assuming JSON supports comments — the JSON specification does not allow them, unlike JavaScript itself.
  • Forgetting that JSON keys must always be wrapped in double quotes, not single quotes.
  • Adding a trailing comma after the last item in an object or array, which is invalid JSON.

Professional Tip

Even though JSON's syntax looks almost identical to a JavaScript object literal, it is a stricter, language-independent format. Always validate JSON with a linter or parser rather than assuming JavaScript object rules apply exactly.

Your Turn

Write a JSON object describing yourself with your name, age, a list of hobbies, and whether you are currently employed.

Mini Quiz

What does JSON stand for?