$jsonArrayShift[]
$jsonArrayShift removes the first element from a JSON array and returns it — the equivalent of JavaScript’s Array.shift() (FIFO queues). The remaining elements move one position down. Strings, numbers and booleans are returned as text, objects and arrays as compact JSON.
Syntax
$jsonArrayShift[(key);(...)]
Parameters
The path is given as separate arguments, one per level (no dot notation: a.b is a single key named a.b). Surrounding spaces are removed and empty arguments are skipped. A whole-number argument selects an element when the current value is an array; otherwise it is used as an object key. At most 100 arguments are accepted in total. With no argument, the whole document is targeted.
Behavior
- Shifting from an empty array returns an empty string.
- If the value at the path is missing or is not an array, it is replaced by an empty array and an empty string is returned.
Examples
Extract First Element with Shift
$jsonParse[{"queue":["First","Second","Third"]}]
$var[next;$jsonArrayShift[queue]]
$title[Array Shift (FIFO)]
$description[Next item served: **$var[next]**]
$color[#57F287]
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.