How the mapping works
- Elements become object keys, and the root element is the single top-level key.
- Attributes become keys that start with a prefix, @ by default, so an id attribute becomes the key "@id".
- Repeated elements with the same name become an array.
- Text next to attributes or children goes into a key named #text.
- Empty elements become null.
Example
<person id="1">
<name>Ann</name>
<skills>js</skills>
<skills>php</skills>
</person>becomes a person object with "@id": 1, "name": "Ann" and a skills array holding js and php.
Options
Turn on Convert numbers and booleans to get real JSON numbers and true or false values instead of strings. Numbers with leading zeros, such as 007, and very long digit strings stay as text so no information is lost. Change the attribute prefix, or tick Ignore attributes to drop them completely.
Limits
Some XML features have no neat JSON form. Mixed content, where text and elements are interleaved, keeps the text together in #text. The order of differently named siblings is not preserved, because JSON objects group keys. Comments and processing instructions are dropped, and whitespace around text is trimmed.
To convert back, use the JSON to XML converter. For the differences between the formats, read JSON vs XML.