HTTP & JSON jsonArrayShift

$jsonArrayShift[]

Removes and returns the first item from a JSON array, shifting all other elements down by one index.

Syntax
$jsonArrayShift[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 first element as a string. Returns an empty string if the array is empty.

$jsonArrayShift removes and returns the first element from a JSON array — equivalent to JavaScript’s Array.shift(). This is ideal for FIFO (First In, First Out) queue processing. All remaining elements shift down by one index. Shifting from an empty array returns an empty string.

Examples

Shift the first item

$jsonParse[{"queue":["task1","task2","task3"]}]
Processing: $jsonArrayShift[queue]
Next up: $jsonArrayIndex[queue;0]

Process items in FIFO order

$jsonParse[{"events":["login","click","purchase"]}]
$var[count;$jsonArrayCount[events]]
Event 1: $jsonArrayShift[events]
Event 2: $jsonArrayShift[events]
Remaining: $jsonArrayCount[events]

Drain a queue

$jsonParse[{"messages":["hi","hello","hey"]}]
$jsonForEach[messages]
$jsonArrayShift[messages]
$endJsonForEach