Xano Documentation
Search…
πŸ’‘
Start here
☁️ Your Xano Account
πŸ’²
Special Discount Pricing
Array Filters
Append: Push an element on to the end of an Array within an object and return the updated object.
In this example, we have an Array of [ 1,2,2,1 ] by using the append filter the variable becomes [ 1,2,2,1,100].
Join: Joins an array into a text string via the seperator 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
Count: Return the number of items of an Array.
In this example, we have an Array of [ 1,2,2,1 ] by using the count filter the variable becomes 4.
filter_empty: Returns a new Array with only entries that are not empty ("", null, 0, []).
In this example, we have an Array of [ 1,2,,2,1 ] by using the filter_empty the variable becomes [ 1,2,2,1 ].
first: Get the first entry of an Array.
In this example, we have an Array of [ 1,2,0,2,1 ] by using the first filter the variable becomes 1.
last: Get the last entry of an Array.
In this example, we have an Array of [ 1,2,0,2 ] by using the last filter the variable becomes 2.
merge: Merge the first level of elements of both Arrays together and return the new array.
Example: we have an Array of [ 1,2,0,2,1 ] by using the merge filter the variable becomes [1, 2, 0, 2, 1, "123"].
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:
1
{
2
"a": "test",
3
"b": ["a","b"]
4
}
Copied!
We will set up our second array as var_2 using this JSON:
1
{
2
"c": "hi",
3
"b": ["c","d"]
4
}
Copied!
We will then set up our filter as follows:
var_3 would then become:
1
{
2
"a": "test",
3
"b": ["a",b","c","d"]
4
}{
5
"c": "hi",
6
}
Copied!
pop: Pops the last element of the Array off and returns it.
In this example, we have an Array of [ 1,2,0,2,1 ] by using the pop filter the variable becomes 1.
prepend: Push an element on to the beginning of an Array within an object and return the updated object.
In this example, we have an Array of [ 1,2,0,2,1 ] using the prepend filter the variable becomes [ 23,1,2,0,2,1].
push: Push an element on to the end of an Array within an object and return the updated object.
In this example, we are using the push filter to create the Array [1, 2, 0, 2, 1].
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]
After we apply the remove filter with the value of 3 the array becomes: [1,2,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.
After we apply the remove filter the array becomes: [ { "name":"GM" }, { "name":"Chevrolet" } ]
shift: Shifts the first element of the Array and returns it.
In this example, we have an Array of [ 1,2,0,2,1 ] by using the shift filter the variable becomes 1.
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:
In this example, the Array is being sorted by text type in ascending order.
The result is the Array sorted by text alphabetically and case-sensitive.
In this example, the sort type is now itext, which is case-insensitive.
Here is the result of the Array sorted with itext. Notice the difference case-sensitivity makes.
The example below shows how to use the number sort type:
In this example, we are sorting numerically in ascending order (or lowest to highest).
Here we can see the result of the Array when sorted using the number type.
The example below shows the difference in sorting between natural and number when dealing with alphanumeric values:
In this example, the sort type is natural in ascending order.
The response is the Array sorted in a order that is natural to humans.
In this example, the Array is sorted numerically in ascending order.
Here the Array is sorted numerically. Notice the difference between natural and numeric sort with alphanumeric values.
unique: Returns unique values of an Array.
In this example, we have an Array of [ 1,2,0,2,1 ] using the unique filter the variable becomes [ 1,2,0].
unshift: Push an element to the beginning of an Array and return the new Array.
In this example, we have an Array of [ 1,2,0,2,1 ] using the unshift filter the variable becomes [ 58,1,2,0,2,1].
Last modified 8mo ago
Copy link