📝 LLM & AI

JSON Schema: Describing Data Structures

P
Author
Pyland
📅
Published
30.06.2026
⏱️
Reading time
1 min
👁️
Views
83
🌿
Level
Medium

JSON Schema is a standard for describing the structure of JSON. In the Claude API it is used to define tools (tool use) — it tells Claude exactly which parameters to pass.

Basic Structure

{
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "Название города"
    },
    "units": {
      "type": "string",
      "enum": ["celsius", "fahrenheit"],
      "description": "Единицы измерения"
    }
  },
  "required": ["city"]
}

Data Types

# string
{"type": "string", "description": "Текст"}

# number (int or float)
{"type": "number", "description": "Число"}

# integer (whole numbers only)
{"type": "integer", "description": "Целое число"}

# boolean
{"type": "boolean", "description": "true или false"}

# array
{
    "type": "array",
    "items": {"type": "string"},
    "description": "Список строк"
}

# object (nested)
{
    "type": "object",
    "properties": {
        "x": {"type": "number"},
        "y": {"type": "number"}
    },
    "required": ["x", "y"]
}

Claude API Tool Definition

TOOLS = [
    {
        "name": "search_web",
        "description": "Ищет информацию в интернете. Используй для актуальных данных.",
        "input_schema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Поисковый запрос"
                },
                "max_results": {
                    "type": "integer",
                    "description": "Максимум результатов (1-10)",
                    "default": 3
                }
            },
            "required": ["query"]
        }
    },
    {
        "name": "read_file",
        "description": "Читает содержимое локального файла",
        "input_schema": {
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "Путь к файлу (абсолютный или ~)"
                }
            },
            "required": ["path"]
        }
    }
]

description Is the Most Important Field

Claude selects tools based on description. The more precise the description, the better the agent picks the right tool:

# Bad
{"name": "weather", "description": "Погода"}

# Good
{"name": "get_weather", "description": "Получает текущую погоду и прогноз для города. Используй когда пользователь спрашивает про погоду, температуру, осадки."}

Your reaction to the article

💬 Comments (0)

🔐 Sign in to leave a comment
🚪 Login
💭

No comments yet

Be the first to share your opinion about this article!

🔗 Similar

Similar articles

Continue learning with these materials

📝

What is an ORM

ORM (Object-Relational Mapping) is a technology that lets you work with a database through Python...

📅 30.06.2026 👁️ 131
📝

httpx: A Modern HTTP Client for Python

httpx is a next-generation HTTP client. Its interface is similar to requests, but it supports...

📅 30.06.2026 👁️ 108
📝

AI Agents: ReAct Loop and Autonomous Actions

A chatbot answers questions. An agent takes action: it calls tools, retrieves real data, and...

📅 30.06.2026 👁️ 100

Did you like the article?

Subscribe to our updates and receive new articles first. Grow with PyLand!