Open
Description
Background Information
- Module Version:
3.7.8
- Node/Browser Version:
86.0.4240.80
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
entities.id,entities.name,entities.siblings.entity.name,entities.siblings.relationship_set.relationships.relationship.name
4,Zeus,Exo,Senior
4,Zeus,Chrono,null
Actual Behavior
entities.id,entities.name,entities.siblings.entity.name,entities.siblings.relationship_set.relationships.relationship.name,entities.siblings.relationship_set.relationships
4,Zeus,Exo,Senior,"{""relationship"":{""name"":""Senior""}}"
4,Zeus,Chrono,null,
Data Sample
JSON:
{
"entities":
{
"id": 4,
"name": "Zeus",
"siblings": [
{
"entity": {
"name": "Exo",
},
"relationship_set": {
"relationships": [
{
"relationship": {
"name": "Senior"
},
},
]
}
},
{
"entity": {
"name": "Chrono"
},
"relationship_set": {
"relationships": []
}
}
]
}
}
Code Example
// Please include a simple example to replicate the issue
let converter = require('json-2-csv');
const obj1 = {
"entities":
{
"id": 4,
"name": "Zeus",
"siblings": [
{
"entity": {
"name": "Exo",
},
"relationship_set": {
"relationships": [
{
"relationship": {
"name": "Senior"
},
},
]
}
},
{
"entity": {
"name": "Chrono"
},
"relationship_set": {
"relationships": []
}
}
]
}
}
converter.json2csv(obj1, (err, csv) => {
console.log(csv)
}, { unwindArrays: true, expandArrayObjects: true })