json-2-csv
Advanced tools
Comparing version 3.7.10 to 3.7.11
@@ -8,3 +8,3 @@ { | ||
"description": "A JSON to CSV and CSV to JSON converter that natively supports sub-documents and auto-generates the CSV heading.", | ||
"version": "3.7.10", | ||
"version": "3.7.11", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
@@ -127,2 +127,5 @@ # json-2-csv | ||
* Note: This may result in CSV output that does not map back exactly to the original JSON. | ||
* `useDateIso8601Format` - Boolean - Should date values be converted to an ISO8601 date string? | ||
* Default: `false` | ||
* Note: If selected, values will be converted using `toISOString()` rather than `toString()` or `toLocaleString()` depending on the other options provided. | ||
* `useLocaleFormat` - Boolean - Should values be converted to a locale specific string? | ||
@@ -129,0 +132,0 @@ * Default: `false` |
@@ -85,2 +85,7 @@ export interface ISharedOptions { | ||
/** | ||
* Should dates be output in ISO 8601 "Z" format: | ||
* @default false | ||
*/ | ||
useDateIso8601Format?: boolean; | ||
} | ||
@@ -87,0 +92,0 @@ |
@@ -275,8 +275,10 @@ 'use strict'; | ||
function recordFieldValueToString(fieldValue) { | ||
if (Array.isArray(fieldValue) || utils.isObject(fieldValue) && !utils.isDate(fieldValue)) { | ||
const isDate = utils.isDate(fieldValue); // store to avoid checking twice | ||
if (utils.isNull(fieldValue) || Array.isArray(fieldValue) || utils.isObject(fieldValue) && !isDate) { | ||
return JSON.stringify(fieldValue); | ||
} else if (utils.isUndefined(fieldValue)) { | ||
return 'undefined'; | ||
} else if (utils.isNull(fieldValue)) { | ||
return 'null'; | ||
} else if (isDate && options.useDateIso8601Format) { | ||
return fieldValue.toISOString(); | ||
} else { | ||
@@ -283,0 +285,0 @@ return !options.useLocaleFormat ? fieldValue.toString() : fieldValue.toLocaleString(); |
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
61661
1135
259