We break down how to make a deliberate choice between
JSON and
XML: “data vs document”, primitive typing (
true,
123,
"text",
null), lists, attributes, ordering, and schemas/validation. Using Kotlin examples, we show why the
JsonElement tree is convenient for unstable structures, why it’s worth separating parsing from business validation, and why generation is better done via
buildJsonObject rather than by concatenating strings.