-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I might well be reading the docs wrong, but I don't think there's a way to perform the following operation. Given the input
{"foo": "bar", "baz": 10}
{"foo": "blap", "baz": 11}
{"foo": "bar", "baz": 12}
Get only the objects where .foo == "bar"
, resulting in the output:
{"foo": "bar", "baz": 10}
{"foo": "bar", "baz": 12}
Currently the syntax for conditionals, requires an else case. If this were changed to allow only an if case and to not output a value if the case that doesn't match then the program which supplies the above could be:
./jq 'if .foo == "bar" then . end'
My current work around involves using the else case to output a sentinel value which I grep away before piping back into jq again.