KB Article #177763

XML to JSON conversion does not create an array when there's only a single element

Problem

* When converting XML to JSON, an array with a single element is made into a simple value, rather than an array.

Resolution

-- This is due to the ambiguity of the source data. The parser is able to guess that multiples at the same level should be arrays, but when there is only a single value, it's not able to guess.

It is possible to remove the ambiguity by adding <?xml-multiple element_name?> to the source XML. This will cause Staxon to interpret the data as an array. Further details and an example can be found in the Staxon docs.