JSON Examples
Basic JSON Examples
Simple Object
{
"name": "John Doe",
"age": 30,
"email": "john@example.com"
}
Nested Objects
{
"user": {
"name": "John Doe",
"address": {
"street": "123 Main St",
"city": "New York",
"zip": "10001"
}
}
}
Array of Objects
{
"users": [
{
"id": 1,
"name": "John Doe",
"role": "admin"
},
{
"id": 2,
"name": "Jane Smith",
"role": "user"
}
]
}
API Response Examples
Success Response
{
"status": "success",
"data": {
"id": 123,
"name": "Product Name",
"price": 99.99,
"inStock": true
}
}
Error Response
{
"status": "error",
"code": 404,
"message": "Resource not found",
"details": {
"resource": "user",
"id": "123"
}
}
Complex Data Structures
E-commerce Product
{
"product": {
"id": "P123",
"name": "Smartphone X",
"description": "Latest smartphone with advanced features",
"price": 999.99,
"currency": "USD",
"inStock": true,
"specifications": {
"display": "6.5\" AMOLED",
"processor": "Snapdragon 888",
"memory": "8GB RAM",
"storage": "256GB"
},
"colors": ["black", "white", "blue"],
"reviews": [
{
"user": "User123",
"rating": 5,
"comment": "Excellent product!"
}
]
}
}
Social Media Post
{
"post": {
"id": "P789",
"author": {
"id": "U123",
"name": "John Doe",
"avatar": "https://example.com/avatar.jpg"
},
"content": "Check out this amazing product!",
"media": [
{
"type": "image",
"url": "https://example.com/image.jpg",
"alt": "Product image"
}
],
"likes": 150,
"comments": [
{
"user": "Jane Smith",
"text": "Looks great!",
"timestamp": "2024-03-15T10:30:00Z"
}
],
"timestamp": "2024-03-15T10:00:00Z"
}
}