๐Ÿ“‹ 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