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);