I´ve read similar question regarding this and I can´t find a solution. I am converting a CSV xml file to a json array of objects. The following function does it succesfully:
const csvtojsonV2 = require("csvtojson");
csvtojsonV2().fromFile('./CSV_TO_JSON/file.xml')
.then((jsonObj) => {
console.log(jsonObj)
})
But now I´d like to get that jsonObj and put it in a file inside a folder in my current workspace:
const uuidv1 = require('uuid/v1')
const fs = require('fs')
const path = require('path')
csvtojsonV2().fromFile('./CSV_TO_JSON/file.xml')
.then((jsonObj) => {
var folderNameJSON = uuidv1()
folderNameJSON = 'JSON_CONVERTED'
fs.mkdirSync(folderNameJSON)
fs.writeFileSync(path.join(__dirname, folderNameJSON, 'file.json'), jsonObj)
})
However when I open the file it just appears: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],etc...
¿Is this how it supposed to be seen? How can I make it appear as an array of objects like it appears when I console.log(jsonObj)
in the first code snippet?