JSON (JavaScript Object Notation) is the lingua franca of modern software. Every time you use an app, browse a website, or call an API, JSON is almost certainly flowing behind the scenes. Understanding it is one of the highest-leverage skills for anyone working with technology.

What JSON Looks Like

{
  "name": "Amit",
  "age": 30,
  "is_developer": true,
  "skills": ["Python", "JavaScript", "SQL"],
  "address": {
    "city": "Bangalore",
    "country": "India"
  }
}

That’s it. If you can read the above, you can read JSON.

The Rules

JSON has six data types:

  1. String: Text in double quotes. "hello"
  2. Number: No quotes. 42 or 3.14
  3. Boolean: true or false (lowercase, no quotes)
  4. Null: null (represents nothing)
  5. Array: Ordered list in square brackets. [1, 2, 3]
  6. Object: Key-value pairs in curly braces. {"key": "value"}

And a few syntax rules:

  • Keys must be strings (double quotes required)
  • No trailing commas after the last item
  • No comments (this annoys everyone)
  • Use double quotes, not single quotes

Why JSON Won

Before JSON, XML was the standard data format:

<person>
  <name>Amit</name>
  <age>30</age>
</person>

Compare to JSON:

{"name": "Amit", "age": 30}

JSON is shorter, easier to read, easier to parse, and maps directly to data structures in most programming languages. XML has more features (schemas, namespaces, attributes), but for 90% of use cases, JSON’s simplicity wins.

Where You’ll Encounter JSON

  • APIs: Almost every web API sends and receives JSON. When your weather app fetches the forecast, it gets JSON back.
  • Configuration files: package.json, tsconfig.json, VS Code settings, all JSON.
  • Databases: MongoDB stores documents as JSON (technically BSON). PostgreSQL has native JSON columns.
  • Data exchange: Any time two systems need to share structured data.

Common Mistakes

Missing or extra commas

{
  "a": 1,
  "b": 2,  
}

That trailing comma after 2 is invalid. JSON parsers will reject it.

Single quotes

{'name': 'Amit'}

Invalid. JSON requires double quotes.

Unquoted keys

{name: "Amit"}

Invalid. Keys must be quoted strings.

Comments

{
  "name": "Amit"  // this is a comment
}

Invalid. JSON doesn’t support comments. If you need comments in config files, consider JSONC or YAML instead.

Validating JSON

Paste your JSON into a formatter/validator tool. It will instantly tell you if it’s valid and show you where the error is. When debugging API responses or config files, this is the first thing to do.

Practical Tips

  1. When in doubt about syntax, validate. A missing comma or quote can cause cryptic errors.
  2. Pretty-print JSON for reading (with indentation). Minify for sending over networks.
  3. Most languages have built-in JSON parsing: JSON.parse() in JavaScript, json.loads() in Python, json.Unmarshal() in Go.
  4. If you need comments in config, use YAML or JSONC, not raw JSON.