Functionality exists to specify the path to arrays in your model in the X2JS options. This prevents an array with a single item from being serialized as an object instead of an array. Code-wise, this is accomplished with the following where Items is an array in MyXml:
var x2js = new X2JS({
arrayAccessFormPaths : [
"MyXml.Items"
]
});
How this is accomplished with a recursive model, though? Using Typescript to give an example:
Functionality exists to specify the path to arrays in your model in the X2JS options. This prevents an array with a single item from being serialized as an object instead of an array. Code-wise, this is accomplished with the following where
Items
is an array inMyXml
:How this is accomplished with a recursive model, though? Using Typescript to give an example:
In this example, you would have potentially unlimited
arrayAccessFormPaths
values to account for all the levels ofchildren
inMyEntity
. Eg.