JSON to XML mapping
Object properties become elements, arrays become repeated elements, scalars become text nodes, unsafe element-name characters are normalized, and null uses an explicit null attribute.
XML to JSON mapping
Repeated child elements become arrays, attributes use the reserved @attributes object, and text beside structured children uses #text.
Understand round-trip limits
Mixed-content order, namespace semantics, comments, processing instructions, and original lexical formatting may not round-trip meaningfully.
Keep XML parsing safe
DOCTYPE and entity declarations are rejected, and no external entity, schema, stylesheet, or URL is resolved.
Review the mapping contract
Use this structural mapping only when both systems agree on the same conventions.