Skip to main content
cd ../lexicon
sys/docs/lexicon/json.md
Lexicon
JSON

JSON

JSON is a lightweight, text-based data-interchange format using key-value pairs and ordered lists; validate structure with a schema and strict parser before consuming untrusted input in any workflow.
Difficulty: Introductory
5 min read
Updated 2026-09-13

In plain English

Plain definition

JSON is a lightweight, text-based data-interchange format using key-value pairs and ordered lists; validate structure with a schema and strict parser before consuming untrusted input in any workflow.

Technical Definition

JSON is defined by RFC 8259 as a syntax for representing structured data using six value types: object, array, string, number, boolean and null. An object is an unordered set of name/value pairs enclosed in braces; an array is an ordered list of values enclosed in brackets. JSON text must be encoded in UTF-8 for interchange. The specification defines strict lexical and grammatical rules: strings must use double quotes, numbers follow a defined grammar without leading zeros, and there is no native support for comments, dates, or binary data. JSON does not itself enforce a schema; validation of structure and types is typically delegated to a separate schema language such as JSON Schema.

Operational Relevance

JSON is the de facto payload format for REST and many RPC-style APIs, for configuration files, for log line serialisation, and for message payloads in queues and event streams. Operational workflows that rely on JSON typically involve: generating JSON output from an application or tool, transmitting or storing it, and parsing it back into structured data on the receiving side. Because JSON is plain text, it is easy to inspect, diff and version-control, but it is also easy to produce malformed output through string concatenation, encoding mismatches, or truncated writes, which is why explicit validation before consumption is a routine operational control.

Architecture Relationship

JSON sits at the data-interchange layer of a system rather than being a runtime or platform in itself. It commonly appears alongside HTTP as the request/response body format for APIs, alongside message brokers as the event payload encoding, and alongside configuration management tooling as a file format alternative to YAML or TOML. JSON Schema, JSON Lines (newline-delimited JSON for streaming logs), and JSON Patch are related specifications that extend JSON’s role into validation, streaming and partial-update use cases respectively, without changing the base JSON grammar itself.

Example

A minimal JSON object representing a service health check:

{
  "service": "inventory-api",
  "status": "healthy",
  "checks": ["database", "cache"],
  "uptime_seconds": 86400,
  "degraded": false
}

This example uses all six JSON value types: an object as the root, a string for service and status, an array for checks, a number for uptime_seconds, and a boolean for degraded.

Misunderstanding

A common misunderstanding is treating JSON and JavaScript as interchangeable or assuming JSON supports JavaScript language features such as comments, trailing commas, single-quoted strings, or functions. RFC 8259 permits none of these; a parser that accepts them is implementing a superset or a lenient extension, not standard JSON, and documents relying on that leniency may fail when moved to a strict parser. Another frequent error is assuming key order or duplicate keys are meaningfully defined; the specification treats objects as unordered and leaves duplicate-key handling to the implementation, so behaviour can differ across parsers.

  • JSON Schema — a vocabulary for validating the structure and types of JSON documents.
  • JSON Lines (JSONL) — a convention for streaming or storing one JSON value per line, common in log pipelines.
  • YAML — an alternative human-oriented serialisation format often used for configuration files.
  • REST API — an architectural style that commonly uses JSON as its payload format.

Further Reading

  • RFC 8259, “The JavaScript Object Notation (JSON) Data Interchange Format”, IETF, for the authoritative grammar and encoding rules.

Validating a JSON Workflow Safely

When implementing a bounded JSON-producing or JSON-consuming workflow, validate structure before it reaches downstream systems. In a non-production environment, parse sample output with a strict, standards-compliant parser and confirm it fails closed on malformed input rather than silently coercing it. Confirm the target parser’s version and configuration (for example, whether it enforces UTF-8 and rejects trailing commas) before relying on version-specific behaviour, and keep a known-good sample document available so any change to serialisation logic can be compared against it and rolled back by restoring the prior code or configuration revision if validation fails.