Skip to content

Instantly share code, notes, and snippets.

@monkpit
Created October 21, 2021 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkpit/a6aecd22028fc3bbb75a361b58cba7a5 to your computer and use it in GitHub Desktop.
Save monkpit/a6aecd22028fc3bbb75a361b58cba7a5 to your computer and use it in GitHub Desktop.
Pluck props from array of objects with JQ
echo '[
{"a": "a", "b": "b", "c": "c"},
{"a": "1", "b": "2", "c": "3"},
{"a": "x", "b": "y", "c": "z"}
]' | jq ".[] | {b, c}"
# output:
# {
# "b": "b",
# "c": "c"
# }
# {
# "b": "2",
# "c": "3"
# }
# {
# "b": "y",
# "c": "z"
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment