kaue / jsonexport

{} → :page_facing_up: it's easy to convert JSON to CSV
http://kaue.github.io/jsonexport/
Apache License 2.0
247 stars 41 forks source link

Fails when arrays contain non-string values #17

Closed rawcreative closed 7 years ago

rawcreative commented 7 years ago

When passing an array of objects that contain non-string values, a fatal error is thrown on version 1.5.0.

[ { "id": 1, "status": "processing"}, {"id": 2, "status":"complete"} ];

fails with:

.../node_modules/jsonexport/lib/escape-delimiters.js:29
    var newValue = value.replace(textDelimiterRegex, escapedDelimiter);

TypeError: value.replace is not a function
kaue commented 7 years ago

@rawcreative I just added a validation to the escape-delimiters and i included numbers in the array.js test https://github.com/kauegimenes/jsonexport/blob/master/tests/array.js#L22

@papswell Can you think a better way to solve this?