> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# json_array

> 将SQL数组的每个元素转换为JSON值并返回由这些值组成的JSON数组。

将 SQL 数组的每个元素转换为 JSON 值，并返回由这些 JSON 值组成的 JSON 数组。

**Tip**

所有的 JSON 函数和运算符都列在导航栏和[概述页面](/documents/cn/4.2/sql-reference/sql-functions/json-functions/overview-of-json-functions-and-operators.md)上

通过[生成列](/documents/cn/4.2/sql-reference/sql-statements/generated_columns.md)加速查询

## 语法

```Haskell theme={null}
json_array(value, ...)
```

## 参数

`value`：SQL 数组中的一个元素。仅支持 `NULL` 值和以下数据类型：STRING、VARCHAR、CHAR、JSON、TINYINT、SMALLINT、INT、BIGINT、LARGEINT、DOUBLE、FLOAT 和 BOOLEAN。

## 返回值

返回一个 JSON 数组。

## 示例

示例 1：构造一个由不同数据类型的值组成的 JSON 数组。

```plaintext theme={null}
mysql> SELECT json_array(1, true, 'starrocks', 1.1);

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

示例 2：构造一个空的 JSON 数组。

```plaintext theme={null}
mysql> SELECT json_array();

       -> []
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.