JSON (JavaScript Object Notation) is a text-based data format derived from JavaScript object syntax. It is language-independent, easy for humans to read and write, and easy for machines to parse and generate. JSON has become the standard format for REST API responses and configuration files.
JSON Data Types
- String —
"hello" - Number —
42or3.14 - Boolean —
true/false - Null —
null - Object —
{ "key": "value" } - Array —
[1, 2, 3]
Example JSON Document
{
"id": 1,
"name": "Alice",
"email": "[email protected]",
"roles": ["admin", "editor"],
"active": true
}
JSON vs XML
- JSON is more compact and faster to parse than XML.
- XML supports attributes and namespaces; better for document-centric data.
- JSON is the default for REST APIs; XML remains common in SOAP and enterprise systems.