The Boundaries of JSON ↔ YAML and XML Conversion
The claim that JSON is a subset of YAML only guarantees one direction, and XML has no official JSON mapping at all — everything rests on convention.
Converting between JSON and YAML, XML, CSV, TypeScript, Java, Go, and SQL is never lossless. What matters is being explicit about where the loss happens.
8 articlesThe claim that JSON is a subset of YAML only guarantees one direction, and XML has no official JSON mapping at all — everything rests on convention.
CSV is two-dimensional, JSON is tree-shaped. The hard part of conversion is not the code — it is deciding up front how arrays get flattened and how types are preserved.
Nested structures, inconsistent fields and arrays of arrays are where JSON-to-spreadsheet conversion breaks. Four approaches ordered by time to result, each with trade-offs.
Turning JSON into SQL INSERT hides nested-table splitting, NULL versus missing, escaping and dialect gaps. Runnable statements and comparison tables for each trap.
Generating an interface from sample JSON is half the job: optional fields, null, unions, dates and big integers need a human pass, and types do no runtime validation.
The most-copied command in every tutorial, yq -P input.json > output.yaml, still emits JSON on yq v4. This article benchmarks yq 4.44.6, PyYAML 6.0.3 and js-yaml on a 2.39 MB sample, explains why the input extension decides the output format, and gives correct recipes for batch conversion, quoting, indentation and big-integer precision.
Nine experiments against a real converter: the first-row-keys strategy silently drops fields, null/missing/empty all collapse into blank cells, a 20-digit integer loses precision at JSON.parse time, and dot-collision flattening merges two different keys into one column. How headers are built, which values mutate, and how to pick a strategy by downstream use.
A hands-on look at what a JSON-to-Java generator really emits — numbers become Double, nested objects become static inner classes, and not a single Jackson annotation is produced. Money precision, field renaming, type erasure, unknown fields, and dates are the five things you must add yourself, with copy-paste code for each.