estheban / node-json2xml

A small JSON to XML parser
MIT License
65 stars 29 forks source link

Use of the key "length" results in error #25

Closed kibukamusoke closed 4 years ago

kibukamusoke commented 6 years ago

Hi, Thanks for the great package, I noticed that Use of the key "length" in json results in error.

test code:

let json2xml = require('json2xml');

let test = { length: 10, width: 12 };

console.log(json2xml(test));

error: TypeError: json.forEach is not a function at xml (/Users/Trevor/POLARIS/json2xml_test/node_modules/json2xml/lib/json2xml.js:45:14) at Object. (/Users/Trevor/POLARIS/json2xml_test/index.js:9:13) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Function.Module.runMain (module.js:605:10) at startup (bootstrap_node.js:158:16) at bootstrap_node.js:575:3