Skip to content
HTTP & JSON jsonIndex

$jsonIndex[]

$jsonIndex returns the current iteration index (starting at 0) inside a $jsonForEach block. It takes no argument.

Syntax

bdfd
$jsonIndex[]

Behavior

  • Inside $jsonForEach it is 0 for the first element, 1 for the second, and so on. This is the position in the loop, also for objects (use $jsonKey for the key).
  • Outside a $jsonForEach block it returns an empty string (not 0).

Examples

Numbered list

$jsonParse[{"servers":["Alpha","Beta","Gamma"]}]
$title[Server Lookup]
$jsonForEach[servers]
$addField[Server #$jsonIndex;$jsonValue;yes]
$endJsonForEach
$color[#5865F2]

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.