JSON functions were added in MariaDB 10.2.3.
JSON_DEPTH(json_doc)
Returns the maximum depth of the given JSON document, or NULL if the argument is null. An error will occur if the argument is an invalid JSON document.
SELECT JSON_DEPTH('[]'), JSON_DEPTH('true'), JSON_DEPTH('{}'); +------------------+--------------------+------------------+ | JSON_DEPTH('[]') | JSON_DEPTH('true') | JSON_DEPTH('{}') | +------------------+--------------------+------------------+ | 1 | 1 | 1 | +------------------+--------------------+------------------+ SELECT JSON_DEPTH('[1, 2, 3]'), JSON_DEPTH('[[], {}, []]'); +-------------------------+----------------------------+ | JSON_DEPTH('[1, 2, 3]') | JSON_DEPTH('[[], {}, []]') | +-------------------------+----------------------------+ | 2 | 2 | +-------------------------+----------------------------+ SELECT JSON_DEPTH('[1, 2, [3, 4, 5, 6], 7]'); +---------------------------------------+ | JSON_DEPTH('[1, 2, [3, 4, 5, 6], 7]') | +---------------------------------------+ | 3 | +---------------------------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/json_depth/