zemirco / json2csv

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

Don't flat ObjectId's #175

Closed pmvrmc closed 6 years ago

pmvrmc commented 7 years ago

Hello community,

What do you think about including and extra flag so that flatten won't flat an object if it is an ObjectId (from mongo)?

I'm having this issue where I pass a ObjectId to the csv export and it flattens it into smaller fields: _bsontype and id (with incomprehensible characters).

If you agree with this I can go forward and create the PR for it.

knownasilya commented 7 years ago

Sounds reasonable, go for it. Actually, that might be a good default, no flag necessary.

juanjoDiaz commented 7 years ago

That pull request to the flat library should fix this issue if it get's accepted.

I'll submit shortly a PR to json2csv with the necessary change in this library.

juanjoDiaz commented 7 years ago

Btw, in the meantime, what I currently do is json2csv({ data: JSON.parse(JSON.stringify(myData)), flatten: true }) A bit hackish but do the job...