Conversation
Flatten a Tweet
If you have a json object and want to completely flatten it (perhaps as a first step towards a CSV dump), the following works well:
cat tweet.json | jq '. as $in | reduce leaf_paths as $path ({};. + { ($path | map(tostring) | join(".")): $in | getpath($path) })' This command should output as CSV after flattening.
cat tweet.json | jq -r '. as $in | reduce leaf_paths as $path ({};. + { ($path | map(tostring) | join(".")): $in | getpath($path) }) | [.[]] | '