Advertisement
Back to Format List
JSON Format
JavaScript Object Notation - Lightweight data interchange format
What is JSON?
JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of the JavaScript programming language, but is completely language independent. JSON is easy for humans to read and write, and also easy for machines to parse and generate.
Although JSON was originally designed for JavaScript, almost all modern programming languages now support the JSON data format, making it the standard format for web services and API data exchange.
Syntax Structure
Basic syntax rules and data types for JSON
Basic Rules:
- Data in name/value pairs
- Data separated by commas
- Curly braces hold objects
- Square brackets hold arrays
- Strings use double quotes
Supported Data Types:
string - stringsnumber - numbersboolean - booleansnull - null valuesobject - objectsarray - arraysExamples
Common JSON data structure examples
Simple Object:
{
"name": "John Doe",
"age": 30,
"city": "New York",
"married": true,
"children": null
}Array Example:
[
{
"id": 1,
"name": "Product A",
"price": 99.99,
"inStock": true
},
{
"id": 2,
"name": "Product B",
"price": 149.99,
"inStock": false
}
]Nested Object:
{
"user": {
"id": 123,
"profile": {
"name": "Jane Smith",
"email": "jane@example.com",
"preferences": {
"theme": "dark",
"language": "en-US"
}
},
"tags": ["developer", "technology", "frontend"]
}
}Advantages
- Lightweight, high transmission efficiency
- Human readable, easy to understand
- Supported by almost all programming languages
- Standard format for Web APIs
- Supports nested structures
Disadvantages
- No comment support
- Strict syntax requirements
- Limited data types
- General efficiency for large datasets
- Prone to syntax errors
Common Use Cases
Web Development:
- • REST API data exchange
- • AJAX request response
- • Configuration files
- • Frontend-backend data transmission
Other Fields:
- • NoSQL database storage
- • Log file format
- • Data backup and migration
- • Microservice communication