Task-first JSON patterns with tool links.

Data & Parsing

Use this reference when you need a valid JSON shape quickly. The focus is practical examples you can paste into APIs, configs, and payload tests.

Objects
{
  "name": "Ada",
  "role": "engineer"
}

Example: Useful for API request bodies or configuration examples where you need named fields.

Gotcha: JSON keys and string values must use double quotes, not single quotes.

Arrays
{
  "tags": ["php", "laravel", "testing"]
}

Example: A compact shape for tags, selected items, or IDs that belong together.

Gotcha: Arrays preserve order. If order matters in your app, keep that behavior explicit.

Nested Data
{
  "user": {
    "name": "Ada",
    "email": "ada@example.com"
  }
}

Example: Use nesting when fields belong to the same domain object and should be grouped together.

Gotcha: Deep nesting gets harder to query and maintain. Keep the shape as flat as your app allows.

Types
{
  "is_active": true,
  "archived_at": null
}

Example: Useful when modeling optional values and status flags in a payload.

Gotcha: `true`, `false`, and `null` are bare JSON literals. Do not wrap them in quotes unless you want strings.

Escaping
{
  "message": "She said \"ship it\" today."
}

Example: Use this when embedding user-visible text or snippets that contain double quotes.

Gotcha: If the string content is already escaped by your programming language, do not escape it twice before encoding JSON.



Learn JSON in 10 Minutes

Programs must be written for people to read, and only incidentally for machines to execute.

Abelson and Sussman

CodersTool Categories