I need to extract first object matching my criterium in input stream as a variable (if any), then to process the entire stream.
Turns out, the stream becomes empty if there is no matches:
Input:
{"ID":1}
{"ID":2}
Code resulting in full stream:
[inputs] |
(
first(.[] | select (.ID==1))
) as $match |
.
Code resulting in empty stream:
[inputs] |
(
first(.[] | select (.ID==3))
) as $match |
.
(The only difference between snippets is .ID=={1|3})
How can I make the whole inputs available to downstream filter, whether or not there is a match?