Array Filters

  • append - Push an element on to the end of an array within an object and return the updated object

  • count - Return the number of items of an array

  • diff - Return values from the first array not present in the second. Only values are used for matching.

  • diff_assoc - Return values from the first array not present in the second. Keys and values are used for matching.

  • filter_empty - Returns a new array with only entries that are not empty ("", null, 0, [])

  • first - Returns the first item of an array

  • flatten - Flattens a multi-dimensional array

  • intersect - Return values from the first array that are present in the second. Only values are used for matching.

  • interesct_assoc - Return values from the first array that are present in the second. Keys and values are used for matching.

  • join - Joins an array into a text string via the separator and returns the result

  • last - Returns the last item of an array

  • merge - Merges two arrays

  • merge_recursive - Merge all levels of both arrays

  • pop - Pops the last element of an array off and returns it

  • prepend - Prepend an element on to the beginning of an array

  • push - Push an element on to the end of an array

  • range - Returns array of values between the specified start/stop

  • remove - Remove any elements from the array that match the supplied value and return the new array

  • safe_array - Always return an array from the specified value

  • shift - Shifts the first element off the Array and returns it

  • shuffle - Returns the array in a randomized order

  • slice - Extracts a specific section of an array

  • sort - Sorts an array

  • unique - Returns the array with duplicate values removed

  • unshift - Push an element to the beginning of an Array and return the new array

  • pick - Pick keys from the object to create a new object of just those keys.

  • unpick - Remove keys from the object to create a new object of the remaining keys.

append

Push an element on to the end of an Array within an object and return the updated object.


count

Return the number of items of an Array.


diff / diff_assoc

These filters will return values in the first array that are not present in the second array.

  • diff will only use values for matching

  • diff_assoc will use keys and values for matching


filter_empty

Returns a new Array with only entries that are not empty ("", null, 0, []).


first

Get the first entry of an Array.


flatten

Flattens a multi-level array into a single-level array.


intersect / intersect_assoc

Returns the entries from the first array that are present in the second array.

  • intersect will use values for matching

  • intersect_assoc will use keys and values for matching


join

Joins an array into a text string via the separator and returns the result In the below example, we have an array of [ 1,2,3,4 ] and we use the join filter with the text :hello: The variable becomes 1:hello:2:hello:3:hello:4


last

Get the last entry of an Array.


merge

Merge the first level of elements of both Arrays together and return the new array.


merge_recursive

Merge the elements from all levels of both Arrays together and return the new Array.

We will set up our first array as var_1 using this JSON:

{
"a": "test",
"b": ["a","b"]
}

We will set up our second array as var_2 using this JSON:

{
"c": "hi",
"b": ["c","d"]
}

We will then set up our filter as follows:

var_3 would then become:

{
"a": "test",
"b": ["a",b","c","d"]
}{
"c": "hi",
}

pop

Pops the last element of the Array off and returns it.


prepend

Push an element on to the beginning of an Array within an object and return the updated object.


push

Push an element on to the end of an Array within an object and return the updated object.


range

Returns array of values between the specified start/stop. In this example we have an array [1,2,3,4,5 ] and we are using the filter range with the values of start: 2 and stop 4, this returns the array of [2,3,4]


remove

Remove any elements from the array that match the supplied value and return the new array In this example we have an array [1,2,3,4,5,6]

Let's change the array to a more complex one: [ { "name":"Ford"}, { "name":"GM" }, { "name":"Chevrolet" } ]

In this example we will need to specify the path.


safe_array

Always returns an array. Uses the existing value if it is an array or creates an array of one element.


shift

Shifts the first element off the Array and returns it.


shuffle

Returns the array in a randomized order


slice

Extracts and returns a section of an array

  • offset - what index should the slice start, starting at 0

  • length - how many items to slice


sort

Sort an Array of elements with an optional path inside the element, sort type, and ascending/descending. Sort types include:

  • text - case-sensitive sort for text

  • itext - case-insensitive sort for text

  • number - to sort numerically

  • natural - case-sensitive sort that is alphanumerical and natural to humans

  • inatural - case-insensitive sort that is alphanumerical and natural to humans

Ascending order is performed with a true boolean. Descending order uses a false boolean.

The example below shows the difference between case-sensitivity sort with text and itext:

The example below shows how to use the number sort type:

The example below shows the difference in sorting between natural and number when dealing with alphanumeric values:


unique

Returns unique values of an Array. You can also use this filter with an array of objects by specifying a path to the key you would like to use to judge uniqueness.


unshift

Push an element to the beginning of an Array and return the new Array.


pick/unpick

These filters are meant to be used when dealing with Object field types and are particularly useful if you are receiving a large object, from a webhook for example, where only a few of those records are required for your workflows. You can also use them with an array of objects by specifying a path to the key you would like to make changes to.

Pick: Identify values you would like to keep and the filter will return a new object containing only the values you have selected.

Unpick: Identify values you would like to exclude and the filter will return a new object containing only the fields that weren’t omitted.

Last updated