JSON Example

JSON Examples

Simple Object

{
  "name": "Alice",
  "age": 28,
  "email": "alice@example.com"
}

Nested Object

{
  "user": {
    "id": 1,
    "name": "Bob",
    "address": {
      "street": "456 Oak Ave",
      "city": "Portland",
      "state": "OR",
      "zip": "97201"
    }
  }
}

Array of Objects

{
  "employees": [
    {
      "firstName": "John",
      "lastName": "Doe",
      "department": "Engineering"
    },
    {
      "firstName": "Jane",
      "lastName": "Smith",
      "department": "Marketing"
    }
  ]
}

Complex Example (API Response)

{
  "status": "success",
  "code": 200,
  "data": {
    "users": [
      {
        "id": 1,
        "name": "John",
        "roles": ["admin", "user"],
        "profile": {
          "avatar": "https://example.com/avatar.jpg",
          "bio": "Software developer",
          "social": {
            "twitter": "@john",
            "github": "john-dev"
          }
        },
        "isActive": true,
        "lastLogin": "2025-01-15T10:30:00Z"
      }
    ],
    "pagination": {
      "page": 1,
      "perPage": 10,
      "total": 42
    }
  }
}

JSON Schema Example

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1
    },
    "age": {
      "type": "integer",
      "minimum": 0
    },
    "email": {
      "type": "string",
      "format": "email"
    }
  },
  "required": ["name", "email"]
}