14 ms·
confusingly jq also has a streaming mode https://stedolan.github.io/jq/manual/#Streaming https://stedolan.github.io/jq/manual/#Streaming that streams JSON value
by wwader 4y ago
confusingly jq also has a streaming mode https://stedolan.github.io/jq/manual/#Streaming https://stedolan.github.io/jq/manual/#Streaming that streams JSON values as [<path>,<value>] pairs. This can also be combined with null input and enables one to reduce, foreach etc in a memory efficient way, eg sum all .a in an array without loading the whole array into memory:
$ echo '[{"a":1},{"b":2},{"a":3}]' | jq -n --stream 'reduce (inputs | select(.[0][1:] == ["a"])[1]) as $v (0; .+$v)'
4