zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.72k stars 362 forks source link

Question: How to put null values to ""? (JSONToCSV) #531

Closed aastorkiza closed 3 years ago

aastorkiza commented 3 years ago

When i JSONToCSV it skips the null value, i would like to save it as "" in my csv.

            const resultado = queryResult;
            const opts = { header:false,includeEmptyRows:true}
            const csv = JSONToCSV(resultado,opts);

The csv i get with the null: "MiNombre",,"MiApellido" The csv i need to get: "MiNombre","","MiApellido"

knownasilya commented 3 years ago

Check out the API for fields https://mircozeiss.com/json2csv/#example-fields-option

You can use the value property on a field and return an empty string.

juanjoDiaz commented 3 years ago

You can use the defaultValue option and set it to ""