HTTP & JSON
jsonIndex
$jsonIndex[]
Returns the current iteration index during a $jsonForEach loop. Zero-based — starts at 0 for the first element. Must be called inside a $jsonForEach block.
Syntax
$jsonIndex[]
Return Value
integer
The zero-based index of the current iteration. Returns 0 if called outside a $jsonForEach block.
$jsonIndex returns the current iteration index (0-based) when used inside a $jsonForEach block. This is useful for numbered lists, conditional logic based on position (e.g., treating the first or last element differently), or limiting output to the first N items. Outside of $jsonForEach, it returns 0.
Examples
Display numbered items
$jsonParse[{"items":["apple","banana","cherry"]}]
$jsonForEach[items]
$math[$jsonIndex[]+1]. $jsonValue[]
$endJsonForEach
First item special handling
$jsonParse[{"users":["Alice","Bob","Charlie"]}]
$jsonForEach[users]
$if[$jsonIndex[]==0]
**First**: $jsonValue[]
$else
$jsonValue[]
$endif
$endJsonForEach
Pagination within loop
$jsonParse[$httpResult]
$jsonForEach[results]
$if[$jsonIndex[]<5]
$jsonValue[name]
$endif
$endJsonForEach