Overview
TheJSON_ARRAY_LENGTH() function returns the length of a specified JSON array.
Syntax
This function has the following basic syntax.arrayval. It represents the JSON array which we will count the length.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Oxla has been acquired by Redpanda Data. Read the news here.
JSON_ARRAY_LENGTH() function returns the length of a specified JSON array.
JSON_ARRAY_LENGTH(arrayval JSON)
arrayval. It represents the JSON array which we will count the length.
SELECT JSON_ARRAY_LENGTH('[4, 7, 10, 11, 14, {"vegetables":"spinach","fruits":"melon"}, {"a":"b"}]');
+-------+
| f |
+-------+
| 7 |
+-------+
SELECT JSON_ARRAY_LENGTH('[1, 2, [3, 4]]');
+-------+
| f |
+-------+
| 3 |
+-------+
SELECT JSON_ARRAY_LENGTH('[]');
+-------+
| f |
+-------+
| 0 |
+-------+