Генератор классов из JSON

Преобразуйте пример JSON в классы моделей или интерфейсы TypeScript.

// about

Об этом инструменте

Инструмент определяет структуру JSON и создает исходный код. Проверьте необязательные поля, вложенные объекты и типы.

Как использовать

  1. Вставьте JSON-объект или массив.
  2. Выберите язык и имя корневого класса.
  3. Создайте код, проверьте типы и скопируйте результат.

Зачем используют этот инструмент

  • Превращайте ответы JSON API в модели.
  • Генерируйте код для пяти языков.
  • Проверяйте вложенные объекты и массивы.

Часто задаваемые вопросы (FAQ)

Готова ли модель для продакшена?

Это отправная точка. Проверьте типы и поля по контракту API.

Руководства · Данные · 8 мин чтения

Как исправить синтаксические ошибки JSON: 7 самых частых ошибок и приведение JSON в порядок

Ответы API, конфигурационные файлы, логи — JSON остаётся форматом данных, который разработчики читают чаще всего. И всё же одна запятая или кавычка может вызвать ошибку «Unexpected token». Вот как быстро найти причину.

JSON (JavaScript Object Notation) — текстовый формат, стандартизированный в RFC 8259 и ECMA-404. Он появился в JavaScript, но сейчас поддерживается почти всеми языками. Типов значений всего шесть: строка, число, логическое значение (true/false), null, массив и объект.

{
  "id": 1024,
  "name": "AIBIZAP",
  "active": true,
  "tags": ["tools", "guides"],
  "owner": null
}
Основы JSON, семь ошибок, вызывающих сбои разбора, подводные камни больших чисел и дат, а также как превратить JSON в классы или таблицы базы данных.
Читать →
Сделать с ИИ

Создайте этот инструмент сами с помощью ИИ

Нужна своя версия? Скопируйте промпт в чат с ИИ или сохраните файл навыка для ИИ-агента. В них описаны функции, особые случаи и тесты, которые мы использовали.

Промпт и навык даны на английском — ИИ-инструменты хорошо его понимают.

Промпт-задание для ИИ

Вставьте как есть в Claude, ChatGPT или Gemini.

You are an experienced full-stack web developer. Build a web tool called "Генератор классов из JSON" that meets the requirements below.

## Goal

Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.

## Core features

- Choose C#, Java, Python dataclasses or TypeScript interfaces
- Create separate classes for nested objects
- Infer array element types
- Set the root class name
- Apply each language's naming conventions

## Inputs

- JSON sample
- Target language and root class name

## Outputs

- Generated code
- Summary of inferred types

## Edge cases and handling rules

- Treat null values as nullable types
- Merge differing keys across array elements
- Handle keys that clash with reserved words
- Keep original names for keys with digits or hyphens via serialization attributes

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- {"id":1,"name":"a"} gives int Id and string Name in C#
- Nested objects become separate classes
- Empty arrays become lists of object/any

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

Навык (SKILL.md)

Сохраните как .claude/skills/build-json-class-generator/SKILL.md, чтобы агенты вроде Claude Code использовали его при каждой доработке инструмента.

---
name: build-json-class-generator
description: Use when building or changing a Генератор классов из JSON tool. Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.
---

# Build: Генератор классов из JSON

## Goal

Build a tool that generates C#, Java, Python and TypeScript model classes from a JSON sample.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Choose C#, Java, Python dataclasses or TypeScript interfaces
- Create separate classes for nested objects
- Infer array element types
- Set the root class name
- Apply each language's naming conventions

## Inputs

- JSON sample
- Target language and root class name

## Outputs

- Generated code
- Summary of inferred types

## Rules

- Treat null values as nullable types
- Merge differing keys across array elements
- Handle keys that clash with reserved words
- Keep original names for keys with digits or hyphens via serialization attributes
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] {"id":1,"name":"a"} gives int Id and string Name in C#
- [ ] Nested objects become separate classes
- [ ] Empty arrays become lists of object/any

Советы по работе с ИИ

  • Укажите стек (React, Vue или чистый HTML) в первой строке, чтобы код подошёл к проекту.
  • Попросите ИИ выполнить перечисленные тесты и показать результаты до принятия кода.
  • Не вставляйте настоящие пароли, данные клиентов и API-ключи; используйте примеры.