JSON Common Patterns

Common JSON data structures and patterns

API Response

{
    "status": "success",
    "data": {
        "id": 1,
        "name": "John"
    },
    "message": "User retrieved successfully"
} # standard API response

Error Response

{
    "status": "error",
    "code": 404,
    "message": "User not found",
    "errors": [
        { "field": "id", "message": "Invalid ID" }
    ]
} # error structure

Pagination

{
    "data": [...],
    "pagination": {
        "page": 1,
        "perPage": 10,
        "total": 100,
        "totalPages": 10
    }
} # paginated response

Configuration File

{
    "app": {
        "name": "MyApp",
        "version": "1.0.0"
    },
    "database": {
        "host": "localhost",
        "port": 5432
    }
} # config structure

Timestamps

{
    "id": 1,
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
} # ISO 8601 format