Closed gannons closed 4 years ago
Indeed looks like the problem is because we are doing col || ''
at
https://github.com/kaue/jsonexport/blob/master/lib/parser/csv.js#L89
Thats an pretty easy fix, i would replace that with something like col == null ? '' : col
Feel free to open a pull request for this fix if you have time. Otherwise i will prob work on this later tonight.
We should probably include a test to make sure this does not happen in the future as well.
@gannons thanks for taking the time to report and also for pointing out where the issue is :)
should be fixed in jsonexport v3.0.1
Still having this issue. (ts-node: v9.0.0, nodejs: 14.13.1, jsonexport: v3.0.1) But only on object not on array, for instance:
Input:
const value = {
name: "Bob",
lastName: "Smith",
age: 0,
family: {
name: "Peter",
type: "Father",
size: 0,
},
location: [1231, 3214, 4214, 0],
};
jsonexport(value)
.then(console.log)
.catch(console.error);
Output:
name,Bob
lastName,Smith
age,
family.name,Peter
family.type,Father
family.size,
location,1231;3214;4214;0
Noticed that on upgrading from
2.4.1
to2.5.2
(and also3.0.0
) that the library has started to convert columns with integer values of 0 into "".From a quick look through the code I think this happened due to
https://github.com/kaue/jsonexport/blob/master/lib/parser/csv.js#L89
committed in
https://github.com/kaue/jsonexport/commit/40987acafe5887386e0827680326392d0bb8863f