レッスン 5

JSON to CSV and Flattening 日本語ガイド

日本語の csv json to csv and flattening ガイド: Export object arrays to CSV and flatten nested JSON into spreadsheet-friendly columns.

このコンテンツはまだ日本語で用意されていません。ローカライズが完了するまで English 版を表示しています。

JSON can be nested:

[
  {
    "id": 1,
    "profile": {
      "region": "eu"
    }
  }
]

CSV is flat. To export this for a spreadsheet, nested fields need a column convention:

id,profile.region
1,eu

This is often called flattening.

Arrays need a policy

Arrays inside JSON objects do not map cleanly to a single CSV cell. Common choices are:

  • Keep the array as a JSON string in one cell.
  • Explode the array into multiple rows.
  • Export a separate related CSV file.

The right choice depends on who consumes the CSV.

Missing fields

In an array of objects, not every object has the same keys. A CSV export should build a union of fields and leave missing cells empty.

Key takeaway

JSON → CSV requires flattening decisions. Choose column names that are understandable to the spreadsheet user and reversible enough for your workflow.

Use the JSON to CSV mode to preview flattened columns before sharing the file.

実践したいときは関連する DevCove ツールを使えます。任意であり、このレッスンの必須部分ではありません。

関連ツールを開く

コース概要へ戻る