From 9d576ee7181dd9591ee8eb1df4fdb2db917e2c3c Mon Sep 17 00:00:00 2001 From: Ninja-007 Date: Mon, 29 Mar 2021 22:27:34 +0200 Subject: [PATCH] Does not work with array Issue https://github.com/FlatFilers/csvjson-json2csv/issues/1 --- json2csv.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/json2csv.js b/json2csv.js index 86d7c65..1e2433f 100644 --- a/json2csv.js +++ b/json2csv.js @@ -96,8 +96,8 @@ function convert(data, options) { options || (options = {}); - if (!isObject(data)) throw errorNotAnArray; - if (!Array.isArray(data)) data = [data]; + if (!isObject(data) && !Array.isArray(data)) throw errorNotAnArray; + if (!Array.isArray(data)) data = [data]; var separator = options.separator || ','; if (!separator) throw errorMissingSeparator; @@ -160,4 +160,4 @@ this.CSVJSON.json2csv = convert; } -}).call(this); \ No newline at end of file +}).call(this);