content_image/800565.jpg content_image/800566.jpg content_image/800567.jpg content_image/800568.jpg content_image/800569.jpg
## 12.18.5 Functions That Return JSON Value Attributes 

+------------------------------+ 

mysql> SET @@sql_mode = ’NO_BACKSLASH_ESCAPES’; mysql> SELECT JSON_UNQUOTE(’"\	\\u0032"’); 

<img src='content_image/800565.jpg'>

mysql> SELECT JSON_UNQUOTE(’"	\u0032"’); 

<img src='content_image/800566.jpg'>

The functions in this section return attributes of JSON values. 

• 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. 

mysql> SELECT JSON_DEPTH(’{}’), JSON_DEPTH(’[]’), JSON_DEPTH(’true’); 

<img src='content_image/800567.jpg'>

mysql> SELECT JSON_DEPTH(’[10, 20]’), JSON_DEPTH(’[[], {}]’); 

<img src='content_image/800568.jpg'>

mysql> SELECT JSON_DEPTH(’[10, {"a": 20}]’); 

<img src='content_image/800569.jpg'>

• JSON_LENGTH( json_doc [, path ]) 

Returns the length of a JSON document, or, if a path  argument is given, the length of the value within the document identified by the path. Returns NULL  if any argument is NULL  or the path  argument does not identify a value in the document. An error occurs if the json_doc  argument is not a valid JSON document or the path  argument is not a valid path expression or contains a *  or **  wildcard. 

The length of a document is determined as follows: 

•The length of a scalar is 1. 

•The length of an array is the number of array elements. 

