Collections:
JSON_DEPTH() - Calculating Depth of JSON Value
How to calculate the depth of a JSON (JavaScript Object Notation) value using the JSON_DEPTH() function?
✍: FYIcenter.com
JSON_DEPTH(json) is a MySQL built-in function that
calculates the depth of a JSON (JavaScript Object Notation) value
using the following rules:
For example:
SELECT JSON_DEPTH('{}'), JSON_DEPTH('[]'), JSON_DEPTH('true');
-- +------------------+------------------+--------------------+
-- | JSON_DEPTH('{}') | JSON_DEPTH('[]') | JSON_DEPTH('true') |
-- +------------------+------------------+--------------------+
-- | 1 | 1 | 1 |
-- +------------------+------------------+--------------------+
SELECT JSON_DEPTH('[10, 20]'), JSON_DEPTH('[[], {}]');
-- +------------------------+------------------------+
-- | JSON_DEPTH('[10, 20]') | JSON_DEPTH('[[], {}]') |
-- +------------------------+------------------------+
-- | 2 | 2 |
-- +------------------------+------------------------+
SELECT JSON_DEPTH('[10, {"a": 20}]'), JSON_DEPTH('[10, {"a": [10]}]');
-- +-------------------------------+---------------------------------+
-- | JSON_DEPTH('[10, {"a": 20}]') | JSON_DEPTH('[10, {"a": [10]}]') |
-- +-------------------------------+---------------------------------+
-- | 3 | 4 |
-- +-------------------------------+---------------------------------+
Reference information of the JSON_DEPTH() function:
JSON_DEPTH(json): int Calculates the depth of a JSON (JavaScript Object Notation) value, which is the length of the path that reaches its deepest child member. Arguments, return value and availability: json: Required. The JSON value to be measured. int: Return value. The depth of the JSON value. Available since MySQL 5.7.
⇒ JSON_EXTRACT() - Exacting Members from JSON
⇐ JSON_CONTAINS_PATH() - Finding Path in JSON
2023-12-12, 1383🔥, 0💬
Popular Posts:
How To Download Oracle Database 10g XE in Oracle? If you want to download a copy of Oracle Database ...
How To Use "IF ... ELSE IF ..." Statement Structures in SQL Server Transact-SQL? "IF ... ELSE IF ......
How To Convert a Unicode Strings to Non-Unicode Strings in SQL Server Transact-SQL? Since Unicode ch...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Start the Command-Line SQL*Plus in Oracle? If you Oracle server or client installed on your w...