Glossary

JSON (JavaScript Object Notation)

A lightweight text-based data interchange format derived from JavaScript object literal syntax. It represents structured data using six types — strings, numbers, booleans, null, arrays, and objects — and is the universal format for REST API responses, configuration files, and data serialization across virtually every programming language.

JSON (JavaScript Object Notation) is a text-based data format defined in RFC 8259. It uses a minimal syntax based on JavaScript object literals to represent six data types: strings, numbers, booleans, null, arrays, and objects. JSON is language-independent and has become the universal standard for REST API responses, configuration files, and data exchange between services.

Syntax

{
  "string": "must use double quotes",
  "number": 42,
  "float": 3.14,
  "negative": -7,
  "boolean": true,
  "nothing": null,
  "array": [1, "two", false, null],
  "object": {
    "nested": "value"
  }
}

Strict Rules

  • Strings require double quotes — single quotes are invalid
  • No trailing commas{"a": 1,} is invalid
  • No comments — JSON has no comment syntax
  • No undefined — JavaScript's undefined is not a valid JSON value
  • Keys must be strings
  • true, false, null are lowercase only

Parsing

// Parse
const obj = JSON.parse('{"name": "Alice"}');

// Serialize
const json = JSON.stringify(obj, null, 2); // pretty-printed

// Error handling
try {
  JSON.parse(untrustedInput);
} catch (e) {
  console.error("Invalid JSON");
}

JSON vs YAML

FeatureJSONYAML
CommentsNoYes
Trailing commasNoN/A
String quotesRequired (double)Often optional
Best forAPIs, machine-generatedHuman-authored config
Browser supportNativeRequires library

JSON Schema

JSON Schema validates the structure of JSON documents, providing types, constraints, and documentation:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["id", "name"],
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string", "minLength": 1 }
  }
}

Format and validate JSON with the JSON Formatter Tool.