The other day I was exporting json data from mongodb using mongoexport, and needed a way to exclude certain subdocument fields. mongoexport doesn’t support excluding fields.
jq saved the day.
I piped the output of mongoexport through jq, and piped the output of that to gzip. My pipeline looks like this:
nice mongoexport –db mydb –collection accounts –out – | nice jq -c -M ‘del(.phash) | del(.h[].phash)’ | nice gzip > accounts.json.gz
Whoever wrote jq, thank you.