Why does one XML item become a value, but two become a JSON array?
Answer: An XML element does not declare whether a child may repeat. In ParseBloom's XML to JSON converter, one child is represented as one value; two or more siblings with the same name become an array. If your receiving code requires an array in both cases, normalize the property after conversion.
The shape changes at the second sibling
<orders><order>A</order></orders>{"orders":{"order":"A"}}<orders><order>A</order><order>B</order></orders>{"orders":{"order":["A","B"]}}These are the single and repeated cases in the kit's published fixture file. They describe this converter's mapping, not a rule that every XML to JSON tool follows.
Make downstream code expect one shape
If your application always iterates over orders, normalize the converted property at the boundary. This changes the consuming code's view; it does not change or re-run the XML conversion.
const value = result.orders.order;
const orders = value === undefined ? [] : Array.isArray(value) ? value : [value];
// orders is an array for zero, one, or many values.
The missing-value check matters if your input may contain no <order> element. Without it, wrapping undefined would create a misleading one-item array. Test your own schema before using this pattern with empty or optional nodes.
Three boundary cases worth checking
| XML input | Expected JSON in this converter | What to inspect |
|---|---|---|
<root><value/><value></value></root> | {"root":{"value":["",""]}} | The two empty elements remain two entries. |
<item id="007">Notebook</item> | {"item":{"_attributes":{"id":"007"},"_text":"Notebook"}} | The identifier remains text; attributes and text have separate keys. |
<r><id>007</id><flag>false</flag></r> | {"r":{"id":"007","flag":"false"}} | Do not silently coerce IDs or flags into numbers or booleans. |
The cases above come from the kit's authored synthetic fixtures. They are not customer data or an independent benchmark of competing tools.
Questions to settle before migration
Can I force every repeated-capable element to be an array during conversion?
This converter infers repetition from the current document. Normalize fields in your receiving code, or define a schema-aware transformation for fields your system knows may repeat.
Does JSON preserve the complete XML document?
No. For example, mixed-content order and comments are outside this tool's round-trip contract. Keep the original XML when you need an archival or byte-for-byte representation. The kit's README lists the mapping limits.
What should I test with my own XML?
Try zero, one, and multiple children with the same name; an empty child; an attribute that looks numeric; and text that looks like a boolean. Compare the output with the shape your receiving code actually expects.