JSON_ARRAY_LENGTH
9min
This article will show you how the JSON_ARRAY_LENGTH() function returns the length of a JSON array.
Overview
The JSON_ARRAY_LENGTH() function returns the length of a specified JSON array.
Syntax
This function has the following basic syntax.
Syntax
|
The required argument for this function is arrayval. It represents the JSON array which we will count the length.
Examples
Case #1: Get a JSON array length with a JSON value
The following example returns the number of elements in the array:
Json array length
|
The function above will return the following result:
Output
|
Case #2: Get a JSON array length with a number
The following example returns the number of elements in the array.
Json array length
|
You will get the final result as follows:
Output
|
Case #3: JSON array length where the array is NULL or empty
This example shows that an empty JSON array will return 0.
Json array length
|
An empty array will return 0 in the final output:
Output
|

Updated 11 May 2023
Did this page help you?
Yes
No