Skip to content

Instantly share code, notes, and snippets.

@gregberns
Last active March 30, 2020 22:47
Show Gist options
  • Save gregberns/e567e20e2bd01cbd0bad1e06fae48e72 to your computer and use it in GitHub Desktop.
Save gregberns/e567e20e2bd01cbd0bad1e06fae48e72 to your computer and use it in GitHub Desktop.
jq - filter keys containing dash

jq can filter keys with dashes (-), but that requires special syntax: [\"field-name\"]

Input:

echo '{"the-long-field-name":"true"}' | jq ". | select(.[\"the-long-field-name\"] != null)"

Output:

{
  "the-long-field-name": "true"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment