dylang / node-xml

Fast and simple Javascript-based XML generator/builder for Node projects.
https://npmjs.org/package/xml
MIT License
274 stars 51 forks source link

Array with null elements crashes program #33

Open JonathanWilbur opened 8 years ago

JonathanWilbur commented 8 years ago

xml({ foo: null }) works fine, but xml({ bar: [ null, null ] }) causes the program to crash. I know it seems like an edge case, but I am converting a JSON document from a database query and some documents contain arrays with null elements.

Here is the stack trace:

events.js:160 throw er; // Unhandled 'error' event ^ TypeError: Cannot convert undefined or null to object at /x/node_modules/xml/lib/xml.js:185:44 at Array.forEach (native) at resolve (/x/node_modules/xml/lib/xml.js:183:24) at add (/x/node_modules/xml/lib/xml.js:47:24) at xml (/x/node_modules/xml/lib/xml.js:89:9) at [REDACTED] at Query. (/x/node_modules/mongoose/lib/model.js:3340:16) at /x/node_modules/kareem/index.js:259:21 at /x/node_modules/kareem/index.js:127:16 at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9)

Natejoestev commented 1 year ago

i would assume this is an intended feature.