Skip to content
general data-formats

JSON (JSON)

json data-format web-development serialization
Plain English

JSON is a way to write structured data as plain text that both humans and computers can easily read. It uses a simple format of key-value pairs (like a label and its value) organized with curly braces and square brackets. When two applications need to share information (a web server sending data to your browser, an API returning search results), they almost always use JSON as the format.

Technical Definition

JavaScript Object Notation (JSON), defined in RFC 8259 and ECMA-404, is a text-based data interchange format derived from JavaScript object literal syntax. It is language-independent and supported by every major programming language.

Data types:

  • String: Unicode text in double quotes ("hello")
  • Number: integer or floating-point (42, 3.14, -1e10)
  • Boolean: true or false
  • Null: null
  • Array: ordered list of values ([1, "two", true])
  • Object: unordered set of key-value pairs ({"key": "value"})

Characteristics:

  • Human-readable and writable
  • Self-describing (keys provide context)
  • No comments allowed (by spec, though some parsers support them)
  • No trailing commas (common source of parse errors)
  • Keys must be double-quoted strings (single quotes are invalid)
  • No date type (dates are typically ISO 8601 strings)

Alternatives and when to use them:

FormatUse Case
JSONAPI responses, config files, data exchange
YAMLConfiguration files, Kubernetes manifests (superset of JSON, allows comments)
TOMLSimple config files (Cargo.toml, pyproject.toml)
Protocol BuffersHigh-performance binary serialization (gRPC)
MessagePackCompact binary JSON alternative

JSON Schema: a vocabulary for validating JSON structure, used for API contracts and form validation.

JSON in practice

{
  "server": {
    "hostname": "web-prod-01",
    "ip": "10.10.10.5",
    "ports": [80, 443],
    "vlans": [
      { "id": 10, "name": "engineering", "subnet": "10.10.10.0/24" },
      { "id": 20, "name": "guest", "subnet": "10.20.20.0/24" }
    ],
    "monitoring": {
      "enabled": true,
      "interval_seconds": 30,
      "alerting": null
    }
  }
}
# Parse JSON with jq (essential CLI tool)
$ echo '{"name":"web-01","ip":"10.0.0.5","tags":["prod","web"]}' | jq .
$ echo '[{"port":80},{"port":443}]' | jq '.[].port'
80
443

# Validate JSON syntax
$ python3 -m json.tool config.json > /dev/null && echo "Valid" || echo "Invalid"
In the Wild

JSON is the de facto standard for data exchange on the web. Every REST API returns JSON, every JavaScript framework consumes JSON, and most configuration files (package.json, tsconfig.json, launch.json) use JSON or JSON-derived formats. In IT infrastructure, JSON is the format for Terraform state files, Docker container inspect output, cloud API responses, and monitoring tool payloads. The jq command-line tool is essential for any engineer working with JSON in scripts and pipelines: it filters, transforms, and extracts data from JSON with a concise query language. When debugging API issues, the ability to read and mentally parse JSON is a fundamental skill. JSON-LD (Linked Data) extends JSON for structured data on the web, powering schema.org markup for SEO.