HTTP & JSON
jsonArrayPop
$jsonArrayPop[]
Removes and returns the last item from a JSON array.
Syntax
$jsonArrayPop[key]
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. |
Return Value
string
The value of the removed last element as a string. Returns an empty string if the array is empty.
$jsonArrayPop removes the last element from a JSON array and returns it — equivalent to JavaScript’s Array.pop(). This is useful for stack-based processing (LIFO — Last In, First Out). Popping from an empty array returns an empty string.
Examples
Pop the last item
$jsonParse[{"stack":["first","second","third"]}]
Popped: $jsonArrayPop[stack]
Remaining count: $jsonArrayCount[stack]
Process items in LIFO order
$jsonParse[{"tasks":["A","B","C"]}]
$var[count;$jsonArrayCount[tasks]]
Processing $jsonArrayPop[tasks]...
Processing $jsonArrayPop[tasks]...
Remaining: $jsonArrayCount[tasks]
Check if pop returned empty
$jsonParse[{"queue":[]}]
$var[item;$jsonArrayPop[queue]]
$if[$var[item]==]
Queue was already empty.
$endif