Skip to main content
Returns the number of elements in a JSON array. Returns NULL if the input is NULL, and raises an error if the input JSON value is not an array.

Syntax

Parameters

ParameterDescriptionSupported input types
<json>The JSON array whose length is taken.JSON

Return Type

The JSON_ARRAY_LENGTH function returns a result of type INTEGER.

Remarks

Only the top-level elements of the array are counted; nested arrays count as a single element each. An untyped string literal is interpreted as JSON, so an explicit ::JSON cast is not required.

Examples

The following examples return the number of elements in a JSON array: