Understanding YAML vs JSON Data Interchange
While JSON (RFC 8259) is the universal standard for web APIs, YAML (YAML Ain't Markup Language) is widely preferred for human-edited configuration files, DevOps pipelines (GitHub Actions, GitLab CI), and container orchestration (Kubernetes, Docker Compose).
Because YAML 1.2 is a superset of JSON, converting YAML to JSON involves resolving YAML-specific language constructs such as block scalars, anchors, aliases, and explicit type tags into strict standard JSON types.
YAML to JSON Mapping Reference
| YAML 1.2 Construct | YAML Example | Converted JSON Output |
|---|---|---|
| Key-Value Mapping | key: value | {"key": "value"} |
| Block Sequence | - item1 - item2 | ["item1", "item2"] |
| Literal Block Scalar | text: | line 1 line 2 | {"text": "line 1\nline 2"} |
| Boolean & Null | active: true deleted: null | {"active": true, "deleted": null} |