Remove blank strings from array with jq?

Viewed 8286

How does one remove blank string items from an array in jq?

This is my best guess, but it doesn't appear to work:

Attempt

echo '["bob","","tim",""]' | jq '[ . [] | if length > 0 then . end ]'

Desired output:

["bob", "tim"]

Error:

. [] | if length > 0 then . end                            
jq: error: Possibly unterminated 'if' statement at <top-level>, line 1:
. [] | if length > 0 then . end       
jq: 2 compile errors
1 Answers
Related