LENGTH
LENGTH returns as an integer the number of items in a collection.
If passed a non-collection, it will throw an error. A collection can be an array, a hash or set, although it is not limited to these.
Function category: Collection
String types are interpreted as collections.

Syntax

LENGTH(arg1)
Arguments
Description
arg1
A collection.

Example

Let's say we're given a response with the following driver information.
1
{
2
"data": {
3
"drivers": [
4
{
5
"id": 31225,
6
"vehicle": "Toyota",
7
"driver_rating": 9
8
},
9
{
10
"id": 89673,
11
"vehicle": "BMW",
12
"driver_rating": 5
13
},
14
{
15
"id": 62744,
16
"vehicle": "Chrysler",
17
"driver_rating": 6
18
}
19
]
20
}
21
}
Copied!
If we want to find the length of the drivers collection, use the following function.
1
# Find number of items in collection
2
LENGTH(data.drivers)
3
4
# Returns 3
Copied!
Last modified 1yr ago
Export as PDF
Copy link