DevTools

JSONフォーマッター

Ali Hub DevToolsでJSONフォーマッターを使用できます。入力確認、結果、プライバシー情報、文書化された制限を明確に示します。

主な入力

保存領域は、ツールがブラウザー内のローカルでバージョン管理され、範囲が限定され、消去可能で、機密でないデータを明示した場合にのみ使用されます。

このツールをインストール

すぐに使えるよう、このツールを端末に追加します。

JSONフォーマッター

有効なJSONに見やすいインデントを付け、入れ子になったデータを確認し、データモデルを変えずに幅を選べます。

JSONを読みやすくする

圧縮されたJSONは転送には便利ですが、開発中に確認するのは難しくなります。フォーマッターはオブジェクトと配列を改行と一定のインデントで表示し、階層、フィールド、予期しない構造をすばやく確認できるようにします。

整形は表示上の処理です。有効な文書を読みやすくしますが、値や関係を変更するものではありません。入力が正しくない場合は、引用符、カンマ、括弧を先に直してください。空白を変えるだけでは構文は修復できません。

JSONの整形とは

JSONはオブジェクト、配列、文字列、数値、真偽値、nullで構成されるテキスト形式です。フォーマッターは構造を読み取り、改行と空白を加えて書き直します。インデントは見た目の深さだけを決め、フィールド追加、キーの並べ替え、JSON Schemaの検証は行いません。

標準JSONではメンバー名と文字列に二重引用符を使います。コメント、末尾のカンマ、NaN、Infinityは一部の言語拡張にはありますが、標準文法にはありません。そのため、JavaScriptのオブジェクトリテラルはJSONとして失敗することがあります。

使い方

  1. ソース欄にJSON文書を貼り付けるか入力します。
  2. 2個または4個のスペースなど、数値のインデントを選びます。
  3. 整形を実行して結果を確認します。エラーが出たらソースを直して再実行します。
  4. コピーする前に、キー、型、値を元の入力と比較します。

整形の方法

  • 先に解析する

    配置を決める前に、入力を一つのJSON値として解釈する必要があります。これにより構文エラーと表示上の選択を分けられます。

  • 入れ子をインデントする

    深さが読みやすさに役立つ場合、オブジェクトと配列を複数行に分けます。選択した幅を各レベルで繰り返します。

  • 読みやすいテキストを出力する

    出力は解析した値の新しいテキスト表現です。空白は変わっても、意図した構造は保たれます。

読みやすい結果だけで、必須フィールドや業務ルールへの適合が証明されるわけではありません。

結果の読み方

結果をテキストとデータの両方として確認します。キー、配列の順序、型、文字列の内容が意図どおりか確認してください。改行と空白の追加は通常の整形結果です。

エラーは、受け入れられるJSON文法としてソースを解析できなかったことを示します。問題の近くにあるカンマ、引用符、括弧、エスケープを確認します。

よくある間違い

JavaScriptのオブジェクトリテラル、YAML、コメント付きJSONは失敗することがあります。二重引用符を使い、末尾のカンマがない標準JSONを使います。

インデントはキーを並べ替えず、必須フィールドも検証しません。これらの作業は整形とは分けてください。

制限

インターフェースで確認できるのはソーステキストと数値インデントです。JSON Schema、JSON5、形式変換、ファイルアップロードの対応を示すものではありません。

大きな文書、重複キー、数値精度、アプリ固有の規則は、データを使うシステムで別途テストしてください。

Use the documented workflow, compare the result with the source, and verify live behavior before relying on this output in production work.

Keep sensitive values out of examples and apply the target platform rules, tests, and review process for the selected locale.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Review the localized result against the source, the documented contract, and live behavior before publication or production use.

Examples

短いオブジェクトを整形

1行のオブジェクトをどう読めますか?

2個のスペースでオブジェクトを送信します。

各プロパティが別の行に表示され、名前と値は変わりません。

入れ子の配列を表示

オブジェクトの配列をどう確認しますか?

2個のスペースで整形を実行します。

括弧とオブジェクトの境界によって配列の階層が見えます。

4個のスペースを選ぶ

幅の広いインデントはいつ便利ですか?

4個のスペースを選び、ソースを整形します。

各レベルがより離れて表示され、大きな画面で確認しやすくなります。

不足した引用符を見つける

名前を引用符で囲まないとどうなりますか?

ソースを送信して応答を確認します。

標準JSONではありません。メンバー名は二重引用符付きの文字列である必要があります。

真偽値を保つ

trueは文字列になりますか?

オブジェクトを整形し、型を比較します。

trueは真偽値のままで、引用符付きのyesは文字列のままです。

nullを保つ

nullはどう表示されますか?

オブジェクトを整形して値を読みます。

nullは明示的なJSON値として残り、欠落したプロパティや空文字列とは異なります。

Frequently asked questions

整形はJSONを検証しますか?

ソースを解析する必要があるため、構文エラーは結果を妨げます。ただしスキーマ、必須フィールド、業務ルールは検証しません。

値は変わりますか?

想定される変更は空白と改行です。非常に大きな数値や重複キーがある場合は結果を比較してください。

単一引用符を使えますか?

標準JSONでは使えません。名前と文字列には二重引用符が必要です。

末尾のカンマが失敗する理由は?

一部の拡張は許可しますが、標準文法は許可しません。整形前に削除してください。

2個と4個、どちらの空白?

プロジェクトやレビューの慣習に合わせます。読みやすさは変わりますが、データモデルは変わりません。

キーは並べ替えられますか?

並べ替えられるとは考えないでください。整形はレイアウトを整えるだけで、並べ替えには別の明示的な設定が必要です。

間違ったJSONを修復できますか?

できません。ソースの引用符、カンマ、括弧、エスケープを修正してください。

整形したJSONは小さくなりますか?

通常はなりません。空白が増えるためです。圧縮JSONは転送向け、整形JSONは人間の確認向けです。

References