Skip to content

Instantly share code, notes, and snippets.

@jmorenoamor
Created March 15, 2020 09:38
Show Gist options
  • Select an option

  • Save jmorenoamor/ab28b97f8848ed606141d37245a259b2 to your computer and use it in GitHub Desktop.

Select an option

Save jmorenoamor/ab28b97f8848ed606141d37245a259b2 to your computer and use it in GitHub Desktop.
XML to JSON transformation sets one item lists to an object, this function forces a value to be a list instead of an object
/*
* XML to JSON transformation sets one item lists to an object
* this function forces value to be a list instead of an object
*/
function assureArray(item) {
return (item ? (Array.isArray(item) ? item : [item]) : []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment