Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query
optimization, and usability that you won’t want to miss.
Computes the length of a JSON map or array.
JSON_LENGTH(json)
SELECT JSON_LENGTH('true');
+---------------------+
| JSON_LENGTH('true') |
+---------------------+
| NULL |
+---------------------+
SELECT JSON_LENGTH('[1,2,3]');
+------------------------+
| JSON_LENGTH('[1,2,3]') |
+------------------------+
| 3 |
+------------------------+
SELECT JSON_LENGTH('{"a": 1, "b": 2}');
+---------------------------------+
| JSON_LENGTH('{"a": 1, "b": 2}') |
+---------------------------------+
| 2 |
+---------------------------------+
A JSON or Javascript null value is distinct from SQL NULL.