Convert JSON to CSV
- install
jq(https://github.com/jqlang/jq/releases)
#!/bin/bash
# Check if the input file is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 input.json output.csv"
exit 1
fi
# Convert JSON to CSV
jq -r '(.[] | [."name", ."age", ."city"] | @csv)' "$1" > "$2"
https://github.com/jqlang/jqhttps://jqlang.org/https://bashscript.net/bash-script-to-convert-json-to-csv/https://www.baeldung.com/linux/jq-command-jsonhttps://www.digitalocean.com/community/tutorials/how-to-transform-json-data-with-jq
Some of the content is generated by AI, please be cautious in identifying it.