レッスン 6

JSON in APIs and Configs 日本語ガイド

日本語の json json in apis and configs ガイド: REST payloads, config files, and JSON compared to XML and YAML.

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

Understanding JSON in context helps you choose formats wisely and read documentation more effectively.

REST APIs

HTTP APIs often use JSON for bodies and sometimes query-less POST payloads:

POST /users HTTP/1.1
Content-Type: application/json

{"name": "Ada", "role": "admin"}

Responses mirror the same format. Status codes live in HTTP headers; JSON carries the business data. Schemas may be documented with OpenAPI, JSON Schema, or prose examples.

Configuration files

Tools like package.json, tsconfig.json, and many CI configs are JSON. Benefits:

  • Easy for programs to parse
  • Widely supported in editors
  • Diff-friendly in version control when formatted

Trade-off: no comments in strict JSON (some tools accept JSONC—a superset with comments—but portable configs stick to standard JSON).

JSON vs XML

JSONXML
VerbosityUsually shorterOften more tags
TypesMinimal (string, number, …)Attributes + text nodes
SchemaJSON Schema, OpenAPIXSD, DTD
Typical use todayWeb APIsLegacy enterprise, documents

JSON vs YAML

YAML is human-friendly for configs and supports comments. It is common in Kubernetes and Docker Compose files. Pitfalls: indentation-sensitive, harder to parse securely at scale. JSON is stricter and safer for untrusted input; YAML is often chosen when humans edit large configs by hand.

Security note

Never eval() JSON text—parse with a dedicated library. For untrusted payloads, validate against a schema and limit size to reduce denial-of-service risk.

Course summary

You now have a foundation in JSON syntax, types, structure, common errors, and real-world usage. Apply this when reading API docs, designing payloads, or reviewing config changes in pull requests.

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

関連ツールを開く

コース概要へ戻る