# JSON_ARRAY

> JSON_ARRAY function in StackQL: build a JSON array from a list of values.

Source: https://stackql.io/language-spec/functions/json/json_array

Returns a JSON array whose elements are its arguments.  Strings become JSON strings, numbers JSON numbers and `NULL` JSON `null`; a JSON value produced by another JSON function is embedded as JSON rather than as a string.

See also:  
[[` SELECT `]](/language-spec/select) [[` JSON_OBJECT `]](/language-spec/functions/json/json_object) [[` JSON_GROUP_ARRAY `]](/language-spec/functions/json/json_group_array)

* * * 

## Syntax

```sql
SELECT JSON_ARRAY([value, ...]) FROM <multipartIdentifier>;
```

## Arguments

__*value*__  
Zero or more values.

## Return Value(s)
Returns a JSON array string.

* * *

## Examples

### Build an array from literals

The last element is embedded as an array because it comes from the `JSON` function:

```sql
SELECT JSON_ARRAY(1, 2.5, 'three', NULL, JSON('[4]')) AS v;
```

```
|----------------------------|
|             v              |
|----------------------------|
| [1,2.5,"three",null,[4]]   |
|----------------------------|
```

### Build an array from columns

The following query returns the name, star count and fork count of each repository in a GitHub organization as one array:

```sql
SELECT name, JSON_ARRAY(name, stargazers_count, forks_count) AS stats
FROM github.repos.repos
WHERE org = 'stackql-labs';
```

For more information, see [https://www.sqlite.org/json1.html#jarray](https://www.sqlite.org/json1.html#jarray)
