If pub.json:documentToJSONString gets a document with a list as element it generates an array, even if there is ony one element in it. Your problem probably is in the transformation to the document from the xml. Please have a look into the generated document using debugger, I assume you won’t have a list there if only one element is present. The fields arrays and makeArrays of pub.xml:xmlNodeToDocument allow for explicit control where to generate arrays.
get xmlf file
pub.xml:xmlStringToXMLNode
pub.xml:xmlNodeToDocument – initialise makeArrays=true
pub.json:documentToJSONString
Also test the code with makeArrays=false (You must set makeArrays to false when using documentTypeName to define the structure of an element. Otherwise, an exception will be thrown at run time.)
get xmlf file
pub.xml:xmlStringToXMLNode
pub.xml:xmlNodeToDocument -- initialise makeArrays=true
pub.json:documentToJSONString
Also test the code with makeArrays=false (You must set makeArrays to false when using documentTypeName to define the structure of an element. Otherwise, an exception will be thrown at run time.)