RFC 8259

Standards & Rfcs Jan 6, 2025 JAVASCRIPT

Definition

If JSON is the language that modern applications use to communicate, RFC 8259 is its official dictionary and grammar guide. Published in 2017, this specification is the definitive, current standard for JSON - the data format that powers nearly every API, configuration file, and data exchange on the web today.

You might wonder: we already had RFC 7159 defining JSON, so why did we need another one? The short answer is clarity and consistency. When different systems exchanged JSON, they sometimes ran into problems: one system might encode text in UTF-16, another in UTF-8. One parser might accept duplicate keys, another might reject them. RFC 8259 settled these ambiguities once and for all by mandating UTF-8 encoding and providing clearer guidance on edge cases.

The beauty of JSON, as codified in RFC 8259, is its simplicity. You can learn the entire syntax in about five minutes: objects use curly braces, arrays use square brackets, strings use double quotes, and you have numbers, booleans, and null. That is literally everything. Yet this simple foundation can represent anything from a user’s profile to complex nested data structures with hundreds of fields. It is human-readable (unlike binary formats) and machine-parsable (unlike prose), hitting a sweet spot that has made it the universal language of web data.

Example

Every modern API you use: Whether you are working with Twitter, GitHub, Stripe, or Google Maps, the data goes back and forth as JSON following RFC 8259. Request a user’s profile, and you get back {"name": "Alice", "followers": 1234}. Post a new tweet, and you send {"text": "Hello world!"}.

Configuration files everywhere: From package.json in JavaScript projects to tsconfig.json in TypeScript to settings files in VS Code - JSON is the go-to format for configuration because it is both human-editable and machine-readable.

NoSQL databases: Databases like MongoDB store documents in a JSON-like format (BSON). When you query data or insert records, you are working with JSON structures that follow RFC 8259’s rules.

Browser storage: When web apps store data in localStorage, they typically serialize objects to JSON strings. The RFC ensures this data survives round-trips through parsing and stringifying.

Analogy

The International Language Standard: Just as there are official standards bodies that define languages (like the Real Academia Espanola for Spanish), RFC 8259 is the official standard for JSON. It settles debates about what is “correct” and ensures everyone speaks the same dialect.

The Sheet Music Notation: Musicians worldwide can read the same sheet music because notation follows universal rules. RFC 8259 provides the same universality for data - a developer in Tokyo and one in Toronto will interpret the same JSON identically.

The Metric System of Data: The metric system provides a universal measurement language that works everywhere. RFC 8259 provides a universal data format that works across all programming languages, operating systems, and databases.

The Rosetta Stone: The Rosetta Stone allowed scholars to translate between languages by providing the same text in multiple scripts. JSON serves a similar purpose - it is the common format that allows Java backends to talk to JavaScript frontends, Python scripts to communicate with Go services.

Code Example


// RFC 8259 JSON structure
{
  "string": "Hello, 世界",  // UTF-8 required
  "number": 42,
  "float": 3.14159,
  "boolean": true,
  "null": null,
  "array": [1, 2, 3],
  "object": {
    "nested": "value"
  }
}

// String escaping
{
  "quote": "He said \"Hello\"",
  "newline": "Line 1\nLine 2",
  "unicode": "\u0048\u0065\u006C\u006C\u006F"
}

// Duplicate keys: SHOULD NOT use
{
  "name": "First",
  "name": "Second"  // ← Unpredictable behavior
}

// Safe parsing
try {
  const data = JSON.parse(jsonString);
} catch (e) {
  console.error('Invalid JSON:', e.message);
}