-
Notifications
You must be signed in to change notification settings - Fork 58
Question: How to make the json be converted to csv completely? #102
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi @Jeff-Tian. That's a good point. I had actually changed the module around for v3 so that it was using In fact, I already have the key generation module ( (Same functionality as requested in #80, so it's probably a good time to add it 🙂) |
There are still a few cases that I need to handle in the key extraction module, so unfortunately I won't have an update for |
@mrodrig thank you very much, take your time. |
Thanks for your understanding @Jeff-Tian. I was able to get the key extraction portion fixed up tonight and that's published. There's a slight enhancement that I'd like to add in though so that I can add an option to this module that would allow users to specify the desired behavior (whether they want a JSON.stringify value - which is more reliable when converting back to JSON from CSV - or whether they would like the behavior described in your initial post). Sorry that this is taking longer than I initially expected! |
Just wanted to give a quick update. It's almost there. I have |
* Fixes handling with duplicate key issue using the new option in the deeks module (from mrodrig/deeks#6). Adds functionality for #102. Release 3.2.0
…ays (#103) * feat: add array object expansion functionality * Allow for objects appearing in array values to be expanded and deep-converted to CSV. * fix: remaining behavior fixes after latest deeks update * Fixes handling with duplicate key issue using the new option in the deeks module (from mrodrig/deeks#6). Adds functionality for #102. * chore(release): 3.2.0
Just released this in NPM version If you specify |
Hey guys, can someone demonstrate how to apply the option parameter {expandArrayObjects: true} ? Thanks |
Hi @svrebelo-eth. Sure, happy to help. Here's a quick snippet showing the behavior of just the
This outputs:
The key thing that this feature enables is the iteration of keys across objects inside array values to provide a deeper conversion of the data. For reference, if the option was not provided, the output for this case would be:
One other common use case that I've heard is to "unwind" arrays such that one CSV line will appear for each value contained in the object. For example, using the following options, you would get this output: Options:
Output:
Hope this helps! |
I tried to use this package in my project but met an issue:
Here is my json:
The converted csv is
So I refer this issue as not-completely converted.
I found another npm package: jsonexport can convert the above json to as follows:
This behavior is excellent! I wonder if our json-2-csv package can do it with some magic tweaks?
thanks in advance!
The text was updated successfully, but these errors were encountered: