HTTP & JSON jsonArrayCount

$jsonArrayCount[]

Returns the number of items in a JSON array.

Syntax
$jsonArrayCount[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

integer

The number of elements in the array. Returns 0 for an empty array.

$jsonArrayCount returns the number of elements in a JSON array. This is useful for pagination, boundary checks, conditional logic based on array size, or displaying counts to users. For iteration over all elements, prefer $jsonForEach.

Examples

Count items in an array

$jsonParse[{"fruits":["apple","banana","cherry"]}]
There are $jsonArrayCount[fruits] fruits.

Check if an array is empty

$jsonParse[{"queue":[]}]
$if[$jsonArrayCount[queue]==0]
Queue is empty!
$else
$jsonArrayCount[queue] items waiting.
$endif

Loop using count

$jsonParse[{"users":[{"name":"A"},{"name":"B"}]}]
There are $jsonArrayCount[users] users.