diff --git a/lib/json2csv.js b/lib/json2csv.js index 106fdc2f..1406eb27 100644 --- a/lib/json2csv.js +++ b/lib/json2csv.js @@ -87,7 +87,9 @@ function checkParams(params) { } if (params.flatten) { - params.data = params.data.map(flatten); + params.data = params.data.map(function (data) { + return flatten(data, { useToJSON: true }); + }); } // Set params.fields default to first data element's keys