My request sounds trivial but I could not find a way to do it. I have as input an array of JSON objects:
[
{
\"foo\": 1,
\"bar\": 2
}
If the input array is too large to fit into memory, you can use jq's so-called "streaming parser".
Here is an illustration using a generic approach, that is, it makes no assumptions about the items in the top-level array:
$ echo '[{"foo":"bar"},99,null,{"foo":"baz"}]' |
jq -cn --stream 'fromstream( inputs|(.[0] |= .[1:]) | select(. != [[]]) )'
{"foo":"bar"}
99
null
{"foo":"baz"}
$