Collections:
JSON_LENGTH() - Calculating Length of JSON Value
How to calculate the length of a JSON (JavaScript Object Notation) value using the JSON_LENGTH() function?
✍: FYIcenter.com
JSON_LENGTH(json, path) is a MySQL built-in function that
calculates the length of a JSON (JavaScript Object Notation) value
at the given path location
using the following rules:
For example:
SELECT JSON_LENGTH('[1, 2, {"a": 3}]');
-- +---------------------------------+
-- | JSON_LENGTH('[1, 2, {"a": 3}]') |
-- +---------------------------------+
-- | 3 |
-- +---------------------------------+
SELECT JSON_LENGTH('{"a": 1, "b": {"c": 30}}');
-- +-----------------------------------------+
-- | JSON_LENGTH('{"a": 1, "b": {"c": 30}}') |
-- +-----------------------------------------+
-- | 2 |
-- +-----------------------------------------+
SELECT JSON_LENGTH('{"a": 1, "b": {"c": 30}}', '$.b');
-- +------------------------------------------------+
-- | JSON_LENGTH('{"a": 1, "b": {"c": 30}}', '$.b') |
-- +------------------------------------------------+
-- | 1 |
-- +------------------------------------------------+
Reference information of the JSON_LENGTH() function:
JSON_LENGTH(json, path): int
Calculates the length of a JSON (JavaScript Object Notation) value
at the given path location by counting its members.
Arguments, return value and availability:
json: Required. The JSON value to be observed.
path: Optional. The default is '$'.
The location of a child member to be measured.
int: Return value. The length of the JSON value.
Available since MySQL 5.7.
⇒ JSON_MERGE() - Synonym for JSON_MERGE_PRESERVE()
⇐ JSON_KEYS() - Exacting Keys from JSON Object
2023-12-11, 1069🔥, 0💬
Popular Posts:
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
How To Query Tables and Loop through the Returning Rows in MySQL? The best way to query tables and l...
How To Query Tables and Loop through the Returning Rows in MySQL? The best way to query tables and l...