Collections:
JSON_KEYS() - Exacting Keys from JSON Object
How to extract keys from a JSON (JavaScript Object Notation) object using the JSON_KEYS() function?
✍: FYIcenter.com
JSON_KEYS(json, path) is a MySQL built-in function that
returns keys as a JSON array from a JSON member object at a given
path, specified in the form of "$", "$.key", or "$[i]".
For example:
SET @j = '{"a":null, "b":[1,[2,[3,4]]], "c":{"x":6,"y":[7,[8,9]]}}';
SELECT JSON_KEYS(@j), JSON_KEYS(@j, '$.b'), JSON_KEYS(@j, '$.c');
-- +-----------------+----------------------+----------------------+
-- | JSON_KEYS(@j) | JSON_KEYS(@j, '$.b') | JSON_KEYS(@j, '$.c') |
-- +-----------------+----------------------+----------------------+
-- | ["a", "b", "c"] | NULL | ["x", "y"] |
-- +-----------------+----------------------+----------------------+
Reference information of the JSON_KEYS() function:
JSON_KEYS(json, path): array Returns keys as a JSON array from a JSON member object at a given path, path, specified in the form of "$", "$.key", or "$[i]". Arguments, return value and availability: json: Required. The JSON value to be extracted from. path: Optional. The default is "$". The JSON path to the member object. array: Return value. The extracted keys. Available since MySQL 5.7.
⇒ JSON_LENGTH() - Calculating Length of JSON Value
⇐ JSON_INSERT() - Inserting Members to JSON Value
2023-12-11, 925🔥, 0💬
Popular Posts:
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
How to execute statements in loops in SQL Server Transact-SQL? How to use WHILE ... loops? You can u...
Where to find answers to frequently asked questions on Managing Security, Login and User in SQL Serv...
Where to find Oracle database server tutorials? Here is a collection of tutorials, tips and FAQs for...