Back to Starrocks

json_array

docs/en/sql-reference/sql-functions/json-functions/json-constructor-functions/json_array.md

4.1.0994 B
Original Source

json_array

Converts each element of an SQL array to a JSON value and returns a JSON array that consists of the JSON values.

:::tip All of the JSON functions and operators are listed in the navigation and on the overview page

Accelerate your queries with generated columns :::

Syntax

Haskell
json_array(value, ...)

Parameters

value: an element in the SQL array. Only NULL values and the following data types are supported: STRING, VARCHAR, CHAR, JSON, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, DOUBLE, FLOAT, and BOOLEAN.

Return value

Returns a JSON array.

Examples

Example 1: Construct a JSON array that consists of values of different data types.

plaintext
mysql> SELECT json_array(1, true, 'starrocks', 1.1);

       -> [1, true, "starrocks", 1.1]

Example 2: Construct an empty JSON array.

plaintext
mysql> SELECT json_array();

       -> []