Comparing version 4.5.1 to 4.5.2
@@ -5,3 +5,3 @@ # Change Log | ||
## [4.5.1](https://github.com/zemirco/json2csv/compare/v4.5.0...v4.5.1) (2019-04-30) | ||
## [4.5.2](https://github.com/zemirco/json2csv/compare/v4.5.1...v4.5.2) (2019-07-05) | ||
@@ -11,6 +11,15 @@ | ||
* pretty print when there is no rows ([#390](https://github.com/zemirco/json2csv/issues/390)) ([a20ddfc](https://github.com/zemirco/json2csv/commit/a20ddfc)) | ||
* Improve the inference of the header name when using function as value ([#395](https://github.com/zemirco/json2csv/issues/395)) ([590d19a](https://github.com/zemirco/json2csv/commit/590d19a)) | ||
<a name="4.4.0"></a> | ||
## [4.4.0](https://github.com/zemirco/json2csv/compare/v4.3.5...v4.4.0) (2019-03-25) | ||
### Features | ||
* Performance improvements and new async api ([#360](https://github.com/zemirco/json2csv/issues/360)) ([d59dea1](https://github.com/zemirco/json2csv/commit/d59dea1)) | ||
<a name="4.3.5"></a> | ||
@@ -17,0 +26,0 @@ ## [4.3.5](https://github.com/zemirco/json2csv/compare/v4.3.4...v4.3.5) (2019-02-22) |
@@ -75,3 +75,3 @@ 'use strict'; | ||
if (typeof fieldInfo.value === 'function') { | ||
const label = fieldInfo.label || fieldInfo.value; | ||
const label = fieldInfo.label || fieldInfo.value.name || ''; | ||
const field = { label, default: defaultValue }; | ||
@@ -78,0 +78,0 @@ return { |
{ | ||
"name": "json2csv", | ||
"version": "4.5.1", | ||
"version": "4.5.2", | ||
"description": "Convert JSON to CSV", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -87,2 +87,4 @@ # json2csv | ||
All examples use this example [input file](https://github.com/zemirco/json2csv/blob/master/test/fixtures/json/default.json). | ||
#### Input file and specify fields | ||
@@ -224,3 +226,3 @@ | ||
The synchronous API has the downside of loading the entire JSON array in memory and blocking javascript's event loop while processing the data. This means that you server won't be able to process more request or your UI will become irresponsive while data is being processed. For those reasons, is rarely a good reason to use it unless your data is very small or your application doesn't do anything else. | ||
The synchronous API has the downside of loading the entire JSON array in memory and blocking javascript's event loop while processing the data. This means that your server won't be able to process more request or your UI will become irresponsive while data is being processed. For those reasons, is rarely a good reason to use it unless your data is very small or your application doesn't do anything else. | ||
@@ -351,7 +353,11 @@ The async parser process the data as a non-blocking stream. This approach ensures a consistent memory footprint and avoid blocking javascript's event loop. Thus, it's better suited for large datasets or system with high concurrency. | ||
fields: [ | ||
// Supports pathname -> pathvalue | ||
'simplepath', // equivalent to {value:'simplepath'} | ||
'path.to.value' // also equivalent to {value:'path.to.value'} | ||
// Supports label -> simple path | ||
{ | ||
label: 'some label', // (optional, column will be labeled 'path.to.something' if not defined) | ||
label: 'some label', // Optional, column will be labeled 'path.to.something' if not defined) | ||
value: 'path.to.something', // data.path.to.something | ||
default: 'NULL' // default if value is not found (optional, overrides `defaultValue` for column) | ||
default: 'NULL' // default if value is not found (Optional, overrides `defaultValue` for column) | ||
}, | ||
@@ -361,11 +367,17 @@ | ||
{ | ||
label: 'some label', // Supports duplicate labels (required, else your column will be labeled [function]) | ||
value: (row, field) => row.path1 + row.path2, // field = { label, default } | ||
label: 'some label', // Optional, column will be labeled with the function name or empty if the function is anonymous | ||
value: (row, field) => row[field.label].toLowerCase() ||field.default, | ||
default: 'NULL', // default if value function returns null or undefined | ||
stringify: true // If value is function use this flag to signal if resulting string will be quoted (stringified) or not (optional, default: true) | ||
}, | ||
// Support pathname -> pathvalue | ||
'simplepath', // equivalent to {value:'simplepath'} | ||
'path.to.value' // also equivalent to {value:'path.to.value'} | ||
// Supports label -> derived value | ||
{ | ||
value: (row) => row.arrayField.join(',') | ||
}, | ||
// Supports label -> derived value | ||
{ | ||
value: (row) => `"${row.arrayField.join(',')}"`, | ||
stringify: false // This flag signals if the resulting string should be quoted (stringified) or not (optional, default: true) | ||
}, | ||
] | ||
@@ -372,0 +384,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
435572
853