HTTP & JSON
jsonArrayIndex
$jsonArrayIndex[]
Retrieves the value at a specific index from a JSON array. Index is zero-based.
Syntax
$jsonArrayIndex[key;index]
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | check_circle Required | — | The key identifying the JSON array. The key must exist and contain an array. |
| index | integer | check_circle Required | — | The zero-based index of the element to retrieve. 0 returns the first element. |
Return Value
string
The value at the specified index as a string. Returns an empty string if the index is out of bounds.
$jsonArrayIndex retrieves a single element from a JSON array by its zero-based index. It returns the value as a string. For nested objects, use dot notation with $jsonValue after extracting the element. Out-of-bounds indices return an empty string rather than throwing an error.
Examples
Get the first element
$jsonParse[{"colors":["red","green","blue"]}]
First color: $jsonArrayIndex[colors;0]
Get the last element
$jsonParse[{"items":["a","b","c","d"]}]
$var[last;$math[$jsonArrayCount[items]-1]]
Last: $jsonArrayIndex[items;$var[last]]
Access a specific item
$jsonParse[$httpResult]
Username: $jsonArrayIndex[users;0]