Compact Array

Remove falsy values (null, false, 0, empty strings) from an array.

Code

General
echo "$arr" | jq '[.[] | select(. and . != "" and . != 0 and . != false)]'

Parameters

Array with falsy values (JSON)

Server

More Bash Snippets