Skip to main content

JSON_ARRAY

Description​

Generate a json array containing the specified values, return empty if no values

Syntax​

JSON_ARRAY (<a>, ...)

Parameters​

ParameterDescription
<a>, ...Elements to be included in the JSON array. It can be a single or multiple values of any type, including NULL.

Return Values​

Returns a JSON array containing the specified values. If no values are specified, an empty JSON array is returned.

Examples​

select json_array();
+--------------+
| json_array() |
+--------------+
| [] |
+--------------+
select json_array(null);
+--------------------+
| json_array('NULL') |
+--------------------+
| [NULL] |
+--------------------+
SELECT json_array(1, "abc", NULL, TRUE, CURTIME());
+-----------------------------------------------+
| json_array(1, 'abc', 'NULL', TRUE, curtime()) |
+-----------------------------------------------+
| [1, "abc", NULL, TRUE, "10:41:15"] |
+-----------------------------------------------+
select json_array("a", null, "c");
+------------------------------+
| json_array('a', 'NULL', 'c') |
+------------------------------+
| ["a", NULL, "c"] |
+------------------------------+