You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using your package to convert nested JSON objects to CSV but it is not correctly mapping my JSON Object data to CSV.
I have the sample JSON data, the CSV file, and my Node JS code below.
a) CSV fileform_buggy_test_submissions.csv
b) JSON data[ { "form": { "confirmationId": "5AB5D586", "formName": "form_buggy_test", "version": 1, "createdAt": "2022-11-04T23:11:37.912Z", "fullName": "Ayobami Idowu", "username": "test", "email": "[email protected]" }, "email": "[email protected]", "submit": true, "oneRowPerLake": [ { "dataGrid": [ { "fishType": "rainbow", "numberKept": 1, "numberCaught": 1 }, { "fishType": "cutthroat", "numberKept": 1, "numberCaught": 1 }, { "fishType": "dollyVardon", "numberKept": 1, "numberCaught": 1 }, { "fishType": "smallmouthBass", "numberKept": 2, "numberCaught": 2 } ], "lakeName": "bron", "closestTown": "brondan", "numberOfDays": 1 }, { "dataGrid": [ { "fishType": "rainbow", "numberKept": 2, "numberCaught": 2 }, { "fishType": "cutthroat", "numberKept": 1, "numberCaught": 1 } ], "lakeName": "dran", "closestTown": "dranard", "numberOfDays": 1 } ], "fishermansName": "Ayobami", "didYouFishAnyBcLakesThisYear": "yes", "forWhichBcLakeRegionAreYouCompletingTheseQuestions": 8 } ]
c) JSON Header [ 'form.confirmationId', 'form.formName', 'form.version', 'form.createdAt', 'form.fullName', 'form.username', 'form.email', 'fishermansName', 'email', 'forWhichBcLakeRegionAreYouCompletingTheseQuestions', 'didYouFishAnyBcLakesThisYear', 'oneRowPerLake.lakeName', 'oneRowPerLake.closestTown', 'oneRowPerLake.numberOfDays', 'oneRowPerLake.dataGrid.fishType', 'oneRowPerLake.dataGrid.numberCaught', 'oneRowPerLake.dataGrid.numberKept' ]
d) Node JS
`const options = {
fillGaps: false,
fillTopRow: true,
headerPathString:".",
verticalOutput:false,
// Leaving this option here if we need it. This is the original csv setup where the submission just prints out in 1 column as JSON
//definitions to type cast
typeHandlers: {
Object: function (value, name) {
if (value instanceof Object) {
if (name === 'submission') {
// not really sure what the best representation for JSON is inside a csv...
// this will produce a "" string with all the fields and values like ""field"":""value""
return JSON.stringify(value);
}
}
return value;
}
},
I am using your package to convert nested JSON objects to CSV but it is not correctly mapping my JSON Object data to CSV.
I have the sample JSON data, the CSV file, and my Node JS code below.
a) CSV file form_buggy_test_submissions.csv
b) JSON data
[ { "form": { "confirmationId": "5AB5D586", "formName": "form_buggy_test", "version": 1, "createdAt": "2022-11-04T23:11:37.912Z", "fullName": "Ayobami Idowu", "username": "test", "email": "[email protected]" }, "email": "[email protected]", "submit": true, "oneRowPerLake": [ { "dataGrid": [ { "fishType": "rainbow", "numberKept": 1, "numberCaught": 1 }, { "fishType": "cutthroat", "numberKept": 1, "numberCaught": 1 }, { "fishType": "dollyVardon", "numberKept": 1, "numberCaught": 1 }, { "fishType": "smallmouthBass", "numberKept": 2, "numberCaught": 2 } ], "lakeName": "bron", "closestTown": "brondan", "numberOfDays": 1 }, { "dataGrid": [ { "fishType": "rainbow", "numberKept": 2, "numberCaught": 2 }, { "fishType": "cutthroat", "numberKept": 1, "numberCaught": 1 } ], "lakeName": "dran", "closestTown": "dranard", "numberOfDays": 1 } ], "fishermansName": "Ayobami", "didYouFishAnyBcLakesThisYear": "yes", "forWhichBcLakeRegionAreYouCompletingTheseQuestions": 8 } ]
c) JSON Header
[ 'form.confirmationId', 'form.formName', 'form.version', 'form.createdAt', 'form.fullName', 'form.username', 'form.email', 'fishermansName', 'email', 'forWhichBcLakeRegionAreYouCompletingTheseQuestions', 'didYouFishAnyBcLakesThisYear', 'oneRowPerLake.lakeName', 'oneRowPerLake.closestTown', 'oneRowPerLake.numberOfDays', 'oneRowPerLake.dataGrid.fishType', 'oneRowPerLake.dataGrid.numberCaught', 'oneRowPerLake.dataGrid.numberKept' ]
d) Node JS
`const options = {
fillGaps: false,
fillTopRow: true,
headerPathString:".",
verticalOutput:false,
// Leaving this option here if we need it. This is the original csv setup where the submission just prints out in 1 column as JSON
//definitions to type cast
typeHandlers: {
Object: function (value, name) {
if (value instanceof Object) {
if (name === 'submission') {
// not really sure what the best representation for JSON is inside a csv...
// this will produce a "" string with all the fields and values like ""field"":""value""
return JSON.stringify(value);
}
}
return value;
}
},
#
Help Wanted
@andrew @dydx @cburgmer @jclay
The text was updated successfully, but these errors were encountered: