Created
February 16, 2024 11:05
-
-
Save shana/6a5a87fbf09990adf0cc21a40bb6c448 to your computer and use it in GitHub Desktop.
jq filter array of objects that have an inner array with some entries that matches the given array
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
{ | |
"mirrors": | |
[ | |
{ | |
"type": "A", | |
"platforms": | |
[ | |
"entry1" | |
] | |
}, | |
{ | |
"type": "B", | |
"platforms": | |
[ | |
"entry2" | |
] | |
}, | |
{ | |
"type": "C", | |
"platforms": | |
[ | |
"entry1", | |
"entry2" | |
] | |
} | |
] | |
} | |
jq -rc --arg plat "entry1 entry2" '[.mirrors[]|select([.]|.[].platforms|map([.])|.[] | inside([$plat]))]' < config.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment