JSON_DEPTH(json_doc)

Returns the maximum depth of a JSON document. Returns NULL if the
argument is NULL. An error occurs if the argument is not a valid JSON
document.

An empty array, empty object, or scalar value has depth 1. A nonempty
array containing only elements of depth 1 or nonempty object containing
only member values of depth 1 has depth 2. Otherwise, a JSON document
has depth greater than 2.

URL: http://dev.mysql.com/doc/refman/5.7/en/json-attribute-functions.html

