Home › Data › JSON
Data

JSON

JSON is a simple text format for data. It is how most web APIs send and receive information, and it is easy for both people and programs to read.

The shape

JSON is objects (key-value pairs in braces), arrays (lists in brackets), strings, numbers, booleans, and null. That is the whole format.

{
  "name": "Ada",
  "age": 36,
  "languages": ["Python", "JavaScript"],
  "active": true
}

Using it

Every language can turn JSON text into its own objects and back. In JavaScript that is JSON.parse and JSON.stringify.

const user = JSON.parse(text);
const text = JSON.stringify(user);

Rules

Keys must be in double quotes, no trailing commas, no comments. It is strict on purpose, so it parses the same everywhere.

Keep reading: JavaScript  ·  Web Servers  ·  Cookies