From 83145137ee46cef0ac56803bf32ab02641e7d43a Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Mon, 11 Sep 2017 14:16:12 +0300 Subject: [PATCH 1/2] Use useToJSON option of flat --- lib/json2csv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/json2csv.js b/lib/json2csv.js index 106fdc2f..2e844111 100644 --- a/lib/json2csv.js +++ b/lib/json2csv.js @@ -87,7 +87,7 @@ function checkParams(params) { } if (params.flatten) { - params.data = params.data.map(flatten); + params.data = params.data.map(data => flatten(data, { useToJSON: true })); } // Set params.fields default to first data element's keys From 02e3c3be1c3ee916047987f2f094f0fdf06e169b Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Mon, 11 Sep 2017 14:27:21 +0300 Subject: [PATCH 2/2] Replace ES6 by ES5 --- lib/json2csv.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/json2csv.js b/lib/json2csv.js index 2e844111..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(data => flatten(data, { useToJSON: true })); + params.data = params.data.map(function (data) { + return flatten(data, { useToJSON: true }); + }); } // Set params.fields default to first data element's keys