WEB & API ARCHITECTURE#02 • Modern Data Interchange

JSON Explained: Common Problems, Formatting, and Best Practices.

Why JavaScript Object Notation became a core part of modern web APIs, microservices, and databases. Learn how it works internally, the differences between Bad vs. Good JSON, unformatted vs. formatted payloads, and useful developer tools at PlayWithJSON.

By Shyam KumarFeb 12, 20266 min read
#JSON#RESTAPIs#PlayWithJSON
01 / OVERVIEW

What is JSON and Why It Is Widely Used

JSON (JavaScript Object Notation) is a lightweight, text-based, language-independent data interchange format defined by RFC 8259 and ECMA-404. Although derived from JavaScript object literals, JSON is platform-independent and natively supported across almost every programming language — including Java, Python, C#, Go, Rust, and Node.js.

JSON is widely used for REST APIs, GraphQL responses,microservice communication, and NoSQL document databases such as MongoDB and PostgreSQL's JSONB type.

Internally, working with JSON involves two main processes:

  • Serialization (Stringification): Converting in-memory data structures (like Java objects or Python dictionaries) into a UTF-8 text stream for network transmission or disk storage.
  • Deserialization (Parsing): Parsing raw JSON text into typed, native language objects that applications can read and update.
02 / CORE ADVANTAGES

Advantages of JSON Over XML and Older Formats

Lightweight & Fast

Unlike XML, JSON has no opening and closing tags (<user>...</user>). This reduces the payload size and can reduce network I/O.

Language Agnostic

Most modern languages have well-established JSON libraries (such as Jackson in Java, json in Python, or serde_json in Rust).

Human & Machine Readable

Its key-value and array syntax maps naturally to common data models, making reading and debugging easier.

Flexible Structure

JSON supports nested objects and dynamic structures, allowing API fields to change without breaking existing clients.

03 / SYNTAX INTEGRITY

Bad JSON vs. Good JSON: Common Mistakes That Break Parsers

Because JSON has strict syntax rules, small errors (such as trailing commas or single quotes) cause parsers to fail with a JsonParseException or SyntaxError. Here are some of the most common issues:

BAD JSON (Will throw parser exceptions):
invalid-payload.json(JSON)INVALID SYNTAX
{
    'name': 'Shyam Kumar',       // ERROR 1: Single quotes are not allowed in JSON!
    age: 29,                     // ERROR 2: Keys must be wrapped in double quotes!
    "roles": [
        "Backend Developer",
        "Architect",             // ERROR 3: Trailing comma before closing bracket!
    ],
    "bio": undefined,            // ERROR 4: 'undefined' does not exist in JSON (use null)!
    /* ERROR 5: Comments are not supported in standard JSON! */
}
GOOD JSON (RFC 8259 Compliant):
valid-payload.json(JSON)VALID / FORMATTED
{
  "name": "Shyam Kumar",
  "age": 29,
  "roles": [
  "Backend Developer",
  "Architect"
  ],
  "bio": null,
  "isActive": true
}
04 / READABILITY & DEBUGGING

Unformatted vs. Formatted JSON: Why Indentation Matters

When servers send JSON over HTTP, they typically minify it (removing spaces, newlines, and indentation) to save bandwidth. While this saves bytes over the network, reading unformatted JSON in server logs or during debugging is very difficult.

1. Raw Unformatted JSON (Hard to read and debug):
raw-minified.json(JSON)
{"status":"success","code":200,"data":{"user":{"id":9481,"name":"Shyam Kumar","email":"shyambhati97@gmail.com","verified":true,"skills":["Java","Spring Boot","Kafka","Docker"],"metrics":{"projects":100,"experienceYears":9,"satisfactionRate":1.0}}}}
2. Clean Formatted JSON (2-space indentation, clear hierarchy):
clean-formatted.json(JSON)VALID / FORMATTED
{
  "status": "success",
  "code": 200,
  "data": {
    "user": {
      "id": 9481,
      "name": "Shyam Kumar",
      "email": "shyambhati97@gmail.com",
      "verified": true,
      "skills": [
        "Java",
        "Spring Boot",
        "Kafka",
        "Docker"
      ],
      "metrics": {
        "projects": 100,
        "experienceYears": 9,
        "satisfactionRate": 1.0
      }
    }
  }
}
NEED TO FORMAT YOUR JSON RIGHT NOW?

Format, validate, minify, and inspect messy JSON payloads with 2-space or 4-space indentation. 100% private and in-browser processing.

Open JSON Formatter
05 / RECOMMENDED TOOLING

Developer Tools for Working with JSON: PlayWithJSON

When working with microservices, APIs, and backend pipelines, developers handle JSON daily. Whether you are inspecting tokens, debugging payloads, comparing data diffs, or validating API responses, reliable tools help save time.

A dedicated set of tools built for common JSON workflows is PlayWithJSON (playwithjson.com). It provides client-side JSON tools that process data directly in the browser without sending it to a server.
RECOMMENDED DEVELOPER SUITE

Explore All JSON Tools on PlayWithJSON.com

Free, client-side tools designed for formatting, decoding, and inspecting JSON data.

Visit PlayWithJSON
Back to All Articles in The Tech Corner
Visit PlayWithJSON.com ↗