JSON is a lightweight, human-readable, and widely used data interchange format. It is designed to be easy for both humans to read and write, and for machines to parse and generate. JSON is commonly used for transmitting data between a server and a web application, as well as for configuration files and data storage.
JSON (JavaScript Object Notation) is a text-based format that represents structured data using key-value pairs and arrays. It is derived from JavaScript but is language-independent, meaning it can be used with virtually any programming language. JSON files typically have a .json
extension.
{}
, containing key-value pairs. Example: {"name": "Raj", "age": 30}
[]
, containing a list of values. Example: ["apple", "banana", "cherry"]
:
and a value. Example: "name": "Raj"
true
, false
, or null
. Example: {"isStudent": false, "grades": [90, 85, 88]}
Feature | JSON | XML | YAML |
---|---|---|---|
Readability | High | Moderate | High |
Verbosity | Low | High | Low |
Data Types | Basic (no dates, binary) | Supports complex types | Supports complex types |
Schema Support | No (requires external tools) | Yes (XSD) | No |
Use Case | Web APIs, configuration | Document markup, legacy APIs | Configuration, data serialization |
{}
, arrays []
, key-value pairs "key": value
.