Skip to content

Commit

Permalink
IsArray option isn't parsing tags with 0 as value correctly #490
Browse files Browse the repository at this point in the history
  • Loading branch information
omggga committed Mar 21, 2023
1 parent 292fb78 commit 90021b4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/xmlparser/node2json.js
Expand Up @@ -94,8 +94,20 @@ function assignAttributes(obj, attrMap, jpath, options){
}

function isLeafTag(obj, options){
const { textNodeName } = options;
const propCount = Object.keys(obj).length;
if( propCount === 0 || (propCount === 1 && obj[options.textNodeName]) ) return true;

if (propCount === 0) {
return true;
}

if (
propCount === 1 &&
(obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)
) {
return true;
}

return false;
}
exports.prettify = prettify;

0 comments on commit 90021b4

Please sign in to comment.