Hi lugbz friends,
I have started looking for ways to convert json data into csv format.
For example to convert the json response provided by the Open Data Hub API about the list of accommodations:
http://tourism.opendatahub.bz.it/swagger/ui/index#/Accommodation/Accommodati...
Looking for simple shell tools, I came across jq, which is a powerful tool to filter json streams.
http://manpages.ubuntu.com/manpages/bionic/man1/jq.1.html
Usually it has to be used on the shell, but for playing there is even a handy website providing an online installation of the tool:
Even if I haven't been able yet to convert the json into csv format, still, I think it is a cool tool and worthwhile to be shared with you.
Did someone on the list already use it?
Best regards Patrick
Hi,
I'm late to chime in...
I think it is important to understand that the *hard* part is extracting/remapping the info you need into something flat. From there, it's easy to store it into rows and columns.
How you do that depends on what you already know.
*If* whoever writes these scripts, already knows JavaScript, just coding the script in JavaScript might be the easiest ways:
- you can use Node to run it as a traditional script
- I see you API uses bit masks - you can handle those with JavaScript's biwise opertors (I doubt JQ allows to do this - too lazy to look iy up)
- If you use .filter() .map(), .reduce(), ecc. => functions, the code is going to be pretty compact
I don't think JavaScript is a good language fo all purposes, but for *this* purpose in particular it looks pretty fit if not ideal to me.
If you post what you want to extract from a sample outpust, I can provide some code as an example. If somebody else does the same with JQ we can compare the solutions.
Bye, Chris.