Created
January 28, 2019 00:53
-
-
Save NOLFXceptMe/1422f8b09da8c24c3a6545402bb7a0f4 to your computer and use it in GitHub Desktop.
Notes on jq
This file contains hidden or 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
$ cat excluded.keys | |
"green" | |
"blue" | |
$ cat color-map.json | |
{ | |
"map": [ | |
{ | |
"color": "red", | |
"value": "#f00" | |
}, | |
{ | |
"color": "green", | |
"value": "#0f0" | |
}, | |
{ | |
"color": "blue", | |
"value": "#00f" | |
}, | |
{ | |
"color": "cyan", | |
"value": "#0ff" | |
} | |
] | |
} | |
$ jq --slurpfile excluded excluded.keys '{ "map" : [.map[] | select([.color] | inside($excluded) | not)]}' color-map.json | |
{ | |
"map": [ | |
{ | |
"color": "red", | |
"value": "#f00" | |
}, | |
{ | |
"color": "cyan", | |
"value": "#0ff" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment