I did try this for one customer - both methods above would seem doable for a simple transformation - but anything more complex would take some time and be quite complex.
You need a list of the XPath or JSON paths of those elements you expect to return arrays.
Approaches :
1) Check them in XML, Use XPAth to find all the paths you want as lists but that only one element.
Then use "Add Or Remove XML Element" to add a "dummy" extra node at that point.
Then do the XML -> JSON conversion
then remove all the "dummy" entries via RegEx assertion.
2) After done XML->JSON, then use JSON Path to identify the single nodes, and then directly use regex to manipulate
"nodeexpected":{...} ==> "nodeexpected": [{...}]
3) Write it in java as a custom assertion.
Notes: a) Need to be careful don't remove real data in the regex - since scope is whole document not just sub part.
b) regex is more difficult to find end delimiter with linefeeds , so used non-formatted xml->json transform.
c) An "Add Or Remove JSON Element" assertion would have been useful - but does not exist.
In the sample I was working with, there were nested cases of elements that needed to be arrays, so that would probably mean applying these techniques in a recursive encapsulated assertion, probably best if that walked through the subtree handling each child subtree and returning the converted children - would be needed be fairly tricky.
Cheers - Mark