JSONから各言語のクラスを生成

JSONサンプルをモデルクラスやTypeScriptインターフェースに変換します。

// about

ツールについて

JSONの構造を推測してコードを生成します。省略可能な項目、入れ子、名前、型を確認してください。

使い方

  1. JSONオブジェクトまたは配列を貼り付けます。
  2. 言語とルートクラス名を選びます。
  3. 生成後に型を確認し、コードをコピーします。

このツールが使われる理由

  • JSON APIの応答からモデルコードを作成できます。
  • C#、Java、Python、JavaScript、TypeScriptに対応します。
  • 入れ子のオブジェクトと配列を確認できます。

よくある質問 (FAQ)

本番用の完全なモデルを作れますか?

開始点となるコードです。API仕様に合わせて型やnullを確認してください。

ガイド · データ · 4分で読めます

JSONの構文エラーを直す:よくある7つのミスとJSONの整え方

APIのレスポンス、設定ファイル、ログなど、JSONは開発者が最もよく読むデータ形式です。それでもカンマや引用符ひとつで「Unexpected token」エラーが起こります。原因をすばやく見つける方法を紹介します。

JSON(JavaScript Object Notation)はRFC 8259とECMA-404で標準化されたテキスト形式です。JavaScriptから生まれましたが、今ではほぼすべての言語でサポートされています。値の型は、文字列、数値、真偽値(true/false)、null、配列、オブジェクトの6種類だけです。

{
  "id": 1024,
  "name": "AIBIZAP",
  "active": true,
  "tags": ["tools", "guides"],
  "owner": null
}
JSONの基本、パースエラーの原因になる7つのミス、大きな数値や日付の落とし穴、JSONをクラスやデータベースのテーブルに変換する方法を解説します。
ガイドを読む →
AIで作る

このツールをAIで自作してみましょう

自分用のバージョンが必要なら、作業指示プロンプトをAIチャットに貼り付けるか、スキルファイルをAIコーディングエージェントに保存してください。私たちが開発時に整理した機能、例外、テストケースが含まれています。

プロンプトとスキルは英語で提供しています。AIツールはどの言語でもよく理解できます。

AI作業指示プロンプト

Claude、ChatGPT、GeminiなどのAIチャットにそのまま貼り付けてください。

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 CodeなどのAIコーディングエージェントで .claude/skills/build-json-class-generator/SKILL.md に保存すると、このツールを作る・直すたびに再利用できます。

---
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

AIに任せるときのコツ

  • 最初の行に使用技術(React、Vue、素のHTMLなど)を書くと、プロジェクトに合ったコードになります。
  • コードを受け取る前に、テストケースを実行して結果を見せるよう依頼しましょう。
  • 本物のパスワード、顧客データ、APIキーは入力せず、サンプル値を使ってください。