What is JSON?
JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on JavaScript object literal syntax, but is language-independent, with almost all modern programming languages supporting JSON parsing and generation.
JSON has the following characteristics:
- Easy for humans to read and write
- Easy for machines to parse and generate
- Text-based, completely language-independent
- Widely used for data transmission in web applications
Simple Object
Basic JSON object structure
{
"name": "John Doe",
"age": 30,
"city": "New York"
}User Profile
User information with nested objects
{
"id": 1,
"name": "Alice Smith",
"email": "alice@example.com",
"profile": {
"avatar": "https://example.com/avatar.jpg",
"bio": "Software Developer",
"location": "San Francisco"
},
"preferences": {
"theme": "dark",
"notifications": true
}
}Product List
JSON array containing multiple product objects
[
{
"id": "p001",
"name": "Laptop",
"price": 999.99,
"category": "Electronics",
"inStock": true
},
{
"id": "p002",
"name": "Mouse",
"price": 29.99,
"category": "Accessories",
"inStock": false
}
]API Response
Typical REST API response format
{
"status": "success",
"code": 200,
"message": "Data retrieved successfully",
"data": {
"users": [
{
"id": 1,
"name": "John",
"role": "admin"
},
{
"id": 2,
"name": "Jane",
"role": "user"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 25
}
},
"timestamp": "2024-01-01T12:00:00Z"
}Config File
Application configuration JSON
{
"app": {
"name": "MyApp",
"version": "1.2.0",
"environment": "production"
},
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp_db",
"ssl": true
},
"features": {
"authentication": true,
"logging": true,
"analytics": false
}
}Nested Array
Complex structure with multiple levels of nesting
{
"company": "Tech Corp",
"departments": [
{
"name": "Engineering",
"teams": [
{
"name": "Frontend",
"members": [
"Alice",
"Bob",
"Charlie"
]
},
{
"name": "Backend",
"members": [
"David",
"Eve",
"Frank"
]
}
]
},
{
"name": "Marketing",
"teams": [
{
"name": "Digital",
"members": [
"Grace",
"Henry"
]
}
]
}
]
}Error Response
API error response example
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input parameters",
"details": [
{
"field": "email",
"message": "Email format is invalid"
},
{
"field": "password",
"message": "Password must be at least 8 characters"
}
]
},
"timestamp": "2024-01-01T12:00:00Z",
"requestId": "req_123456789"
}GeoJSON
Geographic location data format
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-74.006,
40.7128
]
},
"properties": {
"name": "New York City",
"population": 8336817
}
}
]
}Package.json
Node.js project configuration file
{
"name": "my-project",
"version": "1.0.0",
"description": "A sample Node.js project",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "jest",
"build": "webpack --mode production"
},
"dependencies": {
"express": "^4.18.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"jest": "^29.0.0",
"webpack": "^5.74.0"
}
}Mixed Data Types
Example containing various JSON data types
{
"string": "Hello World",
"number": 42,
"float": 3.14159,
"boolean": true,
"nullValue": null,
"array": [
1,
"two",
true,
null
],
"object": {
"nested": "value"
},
"emptyArray": [],
"emptyObject": {}
}功能特性
Rich Examples
Provides 10 common JSON data structure examples
One-Click Copy
Click to copy JSON code to clipboard instantly
Syntax Guide
Detailed JSON syntax rules and data type explanations
Privacy Safe
All operations are performed locally, no data uploaded