Last active
May 25, 2016 20:15
-
-
Save holybit/23bc84b041f898aaa8fd0b9781ca1abf to your computer and use it in GitHub Desktop.
JQ filter problem
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
# 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