Loading

Back to Home

$jsonArrayCount

$jsonArrayCount returns the number of elements in a JSON array at the specified key.

Syntax

$jsonArrayCount[Key;...]

What happens

  1. $jsonParse loads the JSON object.
  2. $jsonArrayCount counts the elements in the array at the given key path and returns the number.

Example 1: Count elements in a simple array

$nomention
$jsonParse[{"fruits":["apple","banana","orange"\]}]
$jsonArrayCount[fruits]

What happens:

  1. $jsonParse loads the object with a fruits array of 3 elements.
  2. $jsonArrayCount[fruits] returns the count.

Output:

3

Example 2: Count elements in a nested array

$nomention
$jsonParse[{"store":{"items":["sword","shield","potion","arrow"\]}}]
Items in store: $jsonArrayCount[store;items]

What happens:

  1. $jsonParse loads the object.
  2. $jsonArrayCount[store;items] navigates into store and counts the items array.

Output:

Items in store: 4

Common uses

See also