Skip to content

Instantly share code, notes, and snippets.

@shana
Created February 16, 2024 11:05
Show Gist options
  • Save shana/6a5a87fbf09990adf0cc21a40bb6c448 to your computer and use it in GitHub Desktop.
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
{
"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