📋 JavaScript

JSON Explained — The Data Format That Runs the Web

📅 Jun 22, 2026 ⏱ 3 min read

Every API you will ever call speaks JSON (JavaScript Object Notation) — a text format for structured data that every language understands.

The syntax (stricter than JS)

{
  "name": "Priya",
  "cgpa": 8.9,
  "subjects": ["DS", "OOP"],
  "hostel": null,
  "final": true
}

The two methods

const text = JSON.stringify(obj);        // object → string (send/store)
const obj  = JSON.parse(text);           // string → object (receive/load)
JSON.stringify(obj, null, 2);            // pretty-printed

Where it appears

Debug tip: "Unexpected token in JSON at position 0" almost always means your API returned an HTML error page, not JSON — log the raw response text.

← All Articles