json_array_length
function
Applies to: Databricks SQL Databricks Runtime
Returns the number of elements in the outermost JSON array.
Syntax
json_array_length(jsonArray)
Arguments
jsonArray
: A JSON array.
Returns
An INTEGER.
The function returns NULL if jsonArray
is not a valid JSON string or NULL
.
Examples
> SELECT json_array_length('[1,2,3,4]');
4
> SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]');
5
> SELECT json_array_length('[1,2');
NULL