To convert a JSON file to CSV using the Linux or Unix shell, you can use the jq
command-line tool. Here is an example of how to do this:
jq
by running the following command:sudo apt-get install jq
jq -r '. | keys[] as $k | "\($k),\(.[$k])"' input.json > output.csv
Replace input.json
with the name of your JSON file and output.csv
with the name you want to give to the resulting CSV file.
This command will extract the keys from the JSON object and use them as the column headers in the CSV file. The values will be placed in the corresponding rows.