JSON Templates

Common JSON formats and examples for various use cases

API Responses

REST API Response

Standard REST API response with status, data, and pagination

{
    "status": "success",
    "code": 200,
    "message": "Data retrieved successfully",
    "data": {
        "items": [
            {
                "id": 1,
                "name": "Item 1",
                "description": "Description of item 1"
            },
            {
                "id": 2,
                "name": "Item 2",
                "description": "Description of item 2"
            }
        ],
        "pagination": {
            "total": 100,
            "per_page": 10,
            "current_page": 1,
            "last_page": 10
        }
    }
}

GraphQL Response

GraphQL API response with nested data structure

{
    "data": {
        "user": {
            "id": "1",
            "name": "John Doe",
            "email": "john@example.com",
            "posts": [
                {
                    "id": "101",
                    "title": "First Post",
                    "content": "Content of the first post",
                    "comments": [
                        {
                            "id": "1001",
                            "text": "Great post!",
                            "author": {
                                "id": "2",
                                "name": "Jane Smith"
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Configuration Files

Application Config

Common application configuration settings

{
    "app": {
        "name": "My Application",
        "version": "1.0.0",
        "environment": "production",
        "debug": false
    },
    "database": {
        "host": "localhost",
        "port": 3306,
        "name": "mydb",
        "username": "user",
        "password": "secret"
    },
    "logging": {
        "level": "info",
        "file": "app.log",
        "max_size": "10MB"
    },
    "api": {
        "base_url": "https://api.example.com",
        "timeout": 30,
        "retry_attempts": 3
    }
}

Package.json

Node.js package configuration

{
    "name": "my-package",
    "version": "1.0.0",
    "description": "A sample Node.js package",
    "main": "index.js",
    "scripts": {
        "start": "node index.js",
        "test": "jest",
        "build": "webpack"
    },
    "dependencies": {
        "express": "^4.17.1",
        "lodash": "^4.17.21"
    },
    "devDependencies": {
        "jest": "^27.0.6",
        "webpack": "^5.50.0"
    },
    "author": "John Doe",
    "license": "MIT"
}

Data Structures

User Profile

User profile data structure

{
    "id": "user123",
    "username": "johndoe",
    "email": "john@example.com",
    "profile": {
        "firstName": "John",
        "lastName": "Doe",
        "age": 30,
        "gender": "male",
        "location": {
            "country": "USA",
            "city": "New York"
        }
    },
    "preferences": {
        "theme": "dark",
        "notifications": true,
        "language": "en"
    },
    "createdAt": "2023-01-01T00:00:00Z",
    "lastLogin": "2023-06-15T14:30:00Z"
}

E-commerce Order

E-commerce order data structure

{
    "orderId": "ORD-2023-001",
    "customer": {
        "id": "CUST-001",
        "name": "John Doe",
        "email": "john@example.com",
        "shippingAddress": {
            "street": "123 Main St",
            "city": "New York",
            "state": "NY",
            "zipCode": "10001",
            "country": "USA"
        }
    },
    "items": [
        {
            "productId": "PROD-001",
            "name": "Product 1",
            "quantity": 2,
            "price": 29.99,
            "total": 59.98
        },
        {
            "productId": "PROD-002",
            "name": "Product 2",
            "quantity": 1,
            "price": 49.99,
            "total": 49.99
        }
    ],
    "subtotal": 109.97,
    "tax": 10.99,
    "shipping": 5.99,
    "total": 126.95,
    "status": "processing",
    "createdAt": "2023-06-15T10:30:00Z"
}
Website hosted by HostSlim