Топ-100
 
CerebroSQL

JSON_KEYS

База данных: MySQL

68747470733a2f2f7374796c65732e7265646469746d656469612e636f6d2f74355f32716d366b2f7374796c65

Topic

Syntax:
JSON_KEYS(json_doc[, path])

Returns the keys from the top-level value of a JSON object as a JSON
array, or, if a path argument is given, the top-level keys from the
selected path. Returns NULL if any argument is NULL, the json_doc
argument is not an object, or path, if given, does not locate an
object. 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 result array is empty if the selected object is empty. If the
top-level value has nested subobjects, the return value does not
include keys from those subobjects.

URL: https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html

Example

mysql> SELECT JSON_KEYS('{"a": 1, "b": {"c": 30}}');
+---------------------------------------+
| JSON_KEYS('{"a": 1, "b": {"c": 30}}') |
+---------------------------------------+
| ["a", "b"] |
+---------------------------------------+
mysql> SELECT JSON_KEYS('{"a": 1, "b": {"c": 30}}', '$.b');
+----------------------------------------------+
| JSON_KEYS('{"a": 1, "b": {"c": 30}}', '$.b') |
+----------------------------------------------+
| ["c"] |
+----------------------------------------------+