RFC 8259 Grammar & Payload Minification
Standard JSON formatting converts serial data into structured hierarchical trees, while minification strips whitespace and line feeds to reduce network transport latency.
1. Minification Compression Savings Formula
Savings %=× 100%
Size_formatted − Size_minifiedSize_formatted
2. JSON Primitive Value Domain
Value ∈ { String, Number, Object, Array, Boolean, Null }
Step-by-Step Formatting & Minification Breakdown
Step 1: Lexical Analysis & AST Parsing
Parse raw character stream into tokens, verifying delimiter parity
{ } and [ ].Step 2: Pretty-Print Indentation (2 Spaces)
Formatted payload expanded with hierarchical linebreaks and 2-space tab stops.
Step 3: Minification Byte Reduction
Size Reduction=412 B → 288 B=30.1% Bandwidth Saved
JSON vs JavaScript Data Types Reference
| JSON Type | Valid Example | JavaScript Equivalent | Restrictions |
|---|---|---|---|
| String | "hello world" | String | Must use double quotes (no single quotes) |
| Number | 42, 3.1415, -10 | Number | No NaN, Infinity, or leading zeros |
| Object | {"id": 1} | Object / Record | Keys must be double-quoted strings |
| Array | [1, 2, "three"] | Array | No trailing comma allowed |