Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 598 forks source link

how to set explicitArray=false only for non-child node #646

Open shoysal opened 2 years ago

shoysal commented 2 years ago

I have a object class payment { details [ { FirstName:"goo", LastName:"foo" }, { FirstName:"poo", LastName:"shoo" } ] } I want details object to always be an array even if I have just 1 object in the list. If I set explicitArray=false then if the detail has one object it converts array into an object. I am getting a error in the code as its expecting an array of object and not an object. Is there a way to set explicitArray=false only for non-child node.

Leonidas-from-XIV commented 2 years ago

No, you need to set explicitArray to true and (possibly) post-process.