What Is JSON? (JavaScript Object Notation) Explained
JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format. Originally derived from JavaScript object literal syntax, JSON has become the universal standard for APIs, configuration files, and data storage — supported by every major programming language.
JSON Syntax and Data Types
JSON supports six data types: string (double-quoted, Unicode), number (integer or floating-point), boolean (true or false), null, array (ordered list in []), and object (key-value pairs in {} where keys must be strings). JSON does not support undefined, NaN, Infinity, dates, comments, or trailing commas.
JSON vs XML
JSON is more compact, easier to read, and faster to parse than XML for most use cases. XML supports attributes, namespaces, comments, schemas (XSD), and XSLT transformations — making it preferred for document-centric formats like DOCX, SVG, and RSS. Virtually all modern REST APIs use JSON; XML is common in enterprise/SOAP systems.
JSON Schema
JSON Schema is a vocabulary for describing the structure, types, and constraints of JSON data. It enables automatic validation of API payloads, documentation generation, and IDE autocompletion. Tools like ajv (JavaScript), Pydantic (Python), and most API gateways support JSON Schema validation.
Security Considerations
Never use eval() to parse JSON — use JSON.parse() which is sandboxed. Deeply nested JSON can cause stack overflows in parsers — many implementations limit depth. Very large numbers in JSON may lose precision in JavaScript (beyond Number.MAX_SAFE_INTEGER). For financial data, use string representation of numbers.