About json to xml
XML is still used by many older systems, feeds and enterprise APIs. This tool converts JSON into well-formed XML.
Mapping rules
- Object keys become element names, so keys must be valid XML names.
- Arrays become repeated elements.
- Special characters such as < and & are escaped.
Root element
XML needs a single root element. The tool wraps the data in one if your JSON does not have it.
A worked example
{"user":{"name":"Asha","age":30}} becomes <user><name>Asha</name><age>30</age></user>. An array of items becomes repeated elements with the same name, such as several <item> tags.
Things to watch
- Keys that start with a number or contain spaces are not valid XML names and must be changed.
- XML has no type for numbers or booleans, so everything becomes text.
- Attributes and namespaces need a convention. Agree one with whoever reads the XML.
