Closed pietkamps closed 4 years ago
@pietkamps - just downloaded jsonexport myself and encountered the exact same bug. Specifically if it is an empty value.
i have encountered the same bug with my empty strings. https://github.com/kauegimenes/jsonexport/issues/41#issuecomment-605390380
An online demo tool exists for jsonexport and I used it to check the mentioned data call outs.
Online tool link: https://kauegimenes.github.io/jsonexport/demo/
Here is valid JSON for this tickets mentioned issue. It does NOT convert to CSV correctly (bug confirmed)
[
{
"day": "1",
"time": "12:00",
"persons": [
{
"name": "Bob",
"lastname": "Smith"
},
{
"name": "James",
"lastname": "piet"
},
{
"name": "",
"lastname": "Miller"
},
{
"name": "David",
"lastname": "Martin"
}
]
}
]
Invalid result line 3 and 4:
day,time,persons.name,persons.lastname
1,12:00,Bob,Smith
,,James,piet
,,David,Miller
,,,Martin
Expected Result for line 3 and 4:
day,time,persons.name,persons.lastname
1,12:00,Bob,Smith
,,James,piet
,,,Miller
,,David,Martin
I don't know when but I will attempt a fix in the near future.
Do you want a fix faster? This code is not that difficult, participate, make a pull request.
NOTE TO SELF: Upgrade demo web page. Don't require just JSON and use eval to cast javascript vars (consider security cost of running eval).
@pietkamps I finally got a little time to catch up with jsonexport :) I just opened a PR that fixes this issue https://github.com/kauegimenes/jsonexport/pull/67 @AckerApple can you do a code review?
Fix released as version 2.5.0
Please acquire. Please note we are going to a version 3.0.0 soon
NEW: You should be able to jump to this url to see proof of this fix
I think i found a bug. When i run the following code:
var jsonexport = require('jsonexport'); var invited = [ { day : "1", time : "12:00", persons : [ {name: 'Bob', lastname: 'Smith'}, {name: 'James', lastname: 'piet'}, {name: "", lastname: 'Miller'}, {name: 'David', lastname: 'Martin'} ] } ]
const options = {fillGaps: true}; jsonexport(invited, options, function (err, csv) { if (err) return console.log(err); console.log(csv); });
The output is: day,time,persons.name,persons.lastname 1,12:00,Bob,Smith 1,12:00,James,piet 1,12:00,David,Miller 1,12:00,David,Martin
As you can see the third object has an empty string "". But in the output the name "David" is placed. What i expect of course is an empty string.
I hope the explanation is clear. Thank you in advance, Piet Kamps