JQ

JQ

Lightweight and flexible command-line JSON processor

Category
Text
License
Creative Commons
Platforms
Windows macOS Linux
Released
2013
Path
c:\jq\jq.exe
Version
Latest known: 1.8.1 (2025-07-01)

Examples

1. Generate a CSV file from a JSON data file. (For tab-delimited, change @csv to @tsv.)

jq.exe -r "([\"countryCode\",\"countryName\",\"currencyCode\",\"population\",\"fipsCode\",\"isoNumeric\",\"north\",\"south\",\"east\",\"west\",\"capital\",\"continentName\",\"continent\",\"areaInSqKm\",\"languages\",\"isoAlpha3\",\"geonameId\"] | @csv), (.countries.country[] | [.countryCode, .countryName, .currencyCode, .population, .fipsCode, .isoNumeric, .north, .south, .east, .west, .capital, .continentName, .continent, .areaInSqKm, .languages, .isoAlpha3, .geonameId] | @csv)" d:\countries.json

2. Modify the struct-of-structs that has an array of objects to just a struct with 2-letter country codes as keys.

jq.exe -M ".countries.country | map({key: .countryCode, value: .}) | from_entries" d:\countries.json

Try it

Agree to terms to run demos.