レッスン 4

CSV to JSON for API Fixtures 日本語ガイド

日本語の csv csv to json for api fixtures ガイド: Turn spreadsheet samples into JSON objects for mocks, tests, and docs.

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

CSV is often how sample data arrives. JSON is often how developers need to use it.

For API mocks, tests, and documentation, a header row usually maps well to JSON object keys:

id,name,active
1,Ada,true
[
  {
    "id": 1,
    "name": "Ada",
    "active": true
  }
]

Type inference is a choice

Turning "1" into 1 and "true" into true can be useful for fixtures. But it can be dangerous for:

  • Account IDs with leading zeros
  • ZIP or postal codes
  • Large numeric identifiers
  • Codes that look like numbers but are really strings

Disable type inference when exact text matters.

API fixture checklist

  • Use stable header names that match the API contract.
  • Keep row counts small for unit tests.
  • Preserve strings when IDs or codes need exact formatting.
  • Validate the final JSON with a formatter or schema when the payload matters.

Key takeaway

CSV → JSON is not just a format change. It is a schema decision: keys, types, nulls, and arrays should match the target API.

Use the CSV Converter with type inference on and off to compare fixture output.

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

関連ツールを開く

コース概要へ戻る