JSON
A lightweight, text-based data interchange format that is easy for humans to read and write, and easy for machines to parse and generate.
Also known as: JavaScript Object Notation
Category: Software Development
Tags: software-engineering, programming
Explanation
JSON (JavaScript Object Notation) is a lightweight data interchange format that was specified and popularized by Douglas Crockford in the early 2000s. Despite its name and JavaScript origins, JSON is language-independent and has become the dominant format for data exchange on the web, APIs, and configuration files.
JSON's power lies in its simplicity. It supports six data types: strings, numbers, booleans, null, arrays, and objects. The syntax rules are straightforward: data is organized in key/value pairs, keys must be strings in double quotes, objects use curly braces, arrays use square brackets, and elements are separated by commas. No trailing commas or comments are allowed by the specification.
Common use cases include REST and GraphQL API responses, configuration files (like package.json and tsconfig.json), NoSQL databases (MongoDB, CouchDB), data exchange between services, and structured logging. JSON's ubiquity means virtually every programming language has built-in or readily available JSON parsing libraries.
Compared to alternatives, JSON strikes a balance between readability and simplicity. XML offers schema validation but is verbose. YAML allows comments and is less verbose but is whitespace-sensitive. TOML supports comments and sections but is less common. JSON's lack of comments is often cited as a limitation, but its simplicity and universal support make it the default choice for most data interchange scenarios.
← Back to all concepts