Skip to content

compact

compact(array) → array · Array

Remove null, empty string, and false values from an array.

  • array (required): the array to compact
bash
echo '{"tags": ["urgent", null, "", "review", null, "important"]}' \
  | utlx -e 'compact($input.tags)'
# ["urgent", "review", "important"]
utlx
{
  contacts: compact([
    $input.name,
    $input.email,
    $input.phone
  ])
}
// null values are removed from the resulting array

Released under AGPL-3.0.