Skip to content

Instantly share code, notes, and snippets.

@holybit
Last active May 25, 2016 20:15
Show Gist options
  • Save holybit/23bc84b041f898aaa8fd0b9781ca1abf to your computer and use it in GitHub Desktop.
Save holybit/23bc84b041f898aaa8fd0b9781ca1abf to your computer and use it in GitHub Desktop.
JQ filter problem
# Create jq filter for JSON below that prints "foobar" by testing for which object has Key == "Name" in Tags array.
# However, if the object where Key == "Name" is removed the answer should be null and only one null
{
"Tags": [
{
"Value": "CORE",
"Key": "aws:elasticmapreduce:instance-group-role"
},
{
"Value": "j-2PX6VIU90YUXV",
"Key": "aws:elasticmapreduce:job-flow-id"
},
{
"Value": "foobar",
"Key": "Name"
}
]
}
# json below should print a single null as there is no object where Key == "Name"
{
"Tags": [
{
"Value": "CORE",
"Key": "aws:elasticmapreduce:instance-group-role"
},
{
"Value": "j-2PX6VIU90YUXV",
"Key": "aws:elasticmapreduce:job-flow-id"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment