-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Labels
Description
Background Information
- Module Version:
json-2-csv
- Node/Browser Version:
20.11.0
The issue I'm reporting is with:
- json2csv
- csv2json
I have...
- searched to see if an issue has already been reported.
- verified that my JSON/CSV data is valid (using something like http://jsonlint.com or https://csvlint.io/).
- tried upgrading to the latest version of json-2-csv (since the issue may already be fixed).
Expected Behavior
I need to rename some fields and leave the auto-detect mechanism in place. It would be nice to add a possibility to rename "some" keys when other still will not be filtered out.
Add a new flag that would include all fields that are not specified in keys
option. (for instance includeAutoDetectedKeys
)
Actual Behavior
Currently, there is an option to provide a title only for keys that should be in the final csv file. That means I need to specify all fields I want to see and other fields will be skipped.
{
"field": "string", // required
"title": "string", // optional
"wildcardMatch": false, // optional - default: false
}
When specifying keys as an Object, the field property specifies the key path, while title specifies a more human readable field heading.
Data Sample
JSON:
ANY JSON file
Code Example
// Please include a simple example to replicate the issue
let converter = require('json-2-csv');
json2csv(list, {
escapeHeaderNestedDots: false,
unwindArrays: false,
keys: [{
field: 'data.businessDescription',
title: 'Business Description'
}],
includeAutoDetectedKeys: true,
emptyFieldValue: '',
checkSchemaDifferences: false,
expandNestedObjects: true,
expandArrayObjects: true
})