Comparing version 3.7.0 to 3.7.1
@@ -20,2 +20,3 @@ declare namespace json2csv { | ||
flatten?: boolean; | ||
unwindPath?: string; | ||
excelStrings?: boolean; | ||
@@ -22,0 +23,0 @@ includeEmptyRows?: boolean; |
@@ -16,3 +16,3 @@ /** | ||
* @property {Array} data - array of JSON objects | ||
* @property {Array} fields - see documentation for details | ||
* @property {Array} [fields] - see documentation for details | ||
* @property {String[]} [fieldNames] - names for fields at the same indexes. Must be same length as fields array | ||
@@ -277,2 +277,3 @@ * (Optional. Maintained for backwards compatibility. Use fields config object for more features) | ||
var dataRows = params.data; | ||
if (params.unwindPath) { | ||
@@ -282,3 +283,5 @@ dataRows = []; | ||
var unwindArray = lodashGet(dataEl, params.unwindPath); | ||
if (Array.isArray(unwindArray)) { | ||
var isArr = Array.isArray(unwindArray); | ||
if (isArr && unwindArray.length) { | ||
unwindArray.forEach(function(unwindEl) { | ||
@@ -289,2 +292,6 @@ var dataCopy = lodashCloneDeep(dataEl); | ||
}); | ||
} else if (isArr && !unwindArray.length) { | ||
var dataCopy = lodashCloneDeep(dataEl); | ||
lodashSet(dataCopy, params.unwindPath, undefined); | ||
dataRows.push(dataCopy); | ||
} else { | ||
@@ -295,3 +302,4 @@ dataRows.push(dataEl); | ||
} | ||
return dataRows; | ||
} | ||
} |
{ | ||
"name": "json2csv", | ||
"preferGlobal": "true", | ||
"version": "3.7.0", | ||
"version": "3.7.1", | ||
"description": "Convert JSON to CSV", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276748
6871