JSON
JSON
A lightweight data-interchange format based on JavaScript object notation
Introduction
JSON (JavaScript Object Notation) is a text data format that is easy for humans to read and easy for machines to parse. It represents data as objects of key-value pairs and ordered arrays, and today it is the de facto standard interchange format for web APIs.
Built from just six types — string, number, boolean, null, object, and array — its rules are simple, and nearly every programming language supports it out of the box.
Syntax Features
- Objects are wrapped in curly braces { } and arrays in square brackets [ ].
- Keys must be strings enclosed in double quotes.
- Comments are not supported.
- A comma after the last element (trailing comma) is not allowed.
Pros
- Supported out of the box by almost every language and tool
- Simple rules and fast parsing
- The standard interchange format for web APIs
Cons
- Cannot add comments
- Cumbersome to hand-write in large amounts
- Somewhat verbose as a configuration file
Common Uses
- REST API request and response bodies
- Web app configuration and state storage
- NoSQL document data
Example
[
{ "id": 1, "name": "Ada", "role": "admin" },
{ "id": 2, "name": "Linus", "role": "editor" }
]