Created
February 26, 2021 05:27
-
-
Save jen6/ab27f763c028f94f084fe6c94329a057 to your computer and use it in GitHub Desktop.
AWESOME jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# flatten json | |
jq '. as $in | |
| reduce leaf_paths as $path ({}; | |
. + { ($path | map(tostring) | join(".")): $in | getpath($path) })' target.json | |
# un-flatten json | |
jq 'reduce to_entries[] as $kv ({}; setpath($kv.key|split("."); $kv.value))' ./target.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment