How XML maps to JSON
The converter walks the XML tree with the browser’s built-in parser and produces one JSON object whose single top-level key is the document’s root element. Each child element becomes a key, and its value is whatever the element contains: a scalar for text-only nodes, or a nested object for elements that have their own children or attributes.
Attributes become keys prefixed with an "@" sign. An element like <price currency="USD"> yields "@currency": "USD". Prefixing keeps attributes in the same object as their element while staying clearly separate from child-element keys, so an attribute and a child that happen to share a name never collide.
When an element carries both attributes and text on the same node, the text is stored under a "#text" key next to the "@" attributes. That is how <price currency="USD">18.5</price> becomes { "@currency": "USD", "#text": 18.5 } rather than losing either half of the information.
Text values are type-coerced on the way in: 184.5 becomes a JSON number and true or false become booleans. Identifiers with leading zeros or very long digit runs are deliberately kept as strings, so an id like 007 or a 20-digit account number survives intact instead of being silently rounded.