Outdated Version
You are viewing an older version of this section. View current production version.
JSON_LENGTH
Computes the length of a JSON map or array.
JSON_LENGTH(json)
Arguments
- json: a valid JSON array or map, or the name of a JSON column.
Return Type
- the length as an integer
- SQL NULL if json is not a valid JSON array or map
Examples
mysql> select json_length('true');
+---------------------+
| json_length('true') |
+---------------------+
| NULL |
+---------------------+
mysql> select json_length('[1,2,3]');
+------------------------+
| json_length('[1,2,3]') |
+------------------------+
| 3 |
+------------------------+
Info
A JSON or Javascript null value is distinct from SQL NULL.