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

# json.array

> Creates a new table marked as a JSON array for json.encode, copying the 1.#source sequence when a source table is provided.

Creates a new table marked as a JSON array for json.encode, copying the 1.#source sequence when a source table is provided.

## Syntax

```lua theme={null}
json.array(source?: table): table
```

## Arguments

| Name     | Type    | Required | Description                                                                                                                                                                                    |
| -------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `source` | `table` | No       | Optional source table. When omitted or nil, json.array returns a new empty array-marked table. When provided, only numeric sequence entries from 1 with #source are copied into the new table. |

## Returns

| Name    | Type    | Description                                                                                                                 |
| ------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| `array` | `table` | New table with the JSON array marker. json.encode serializes it as a JSON array; the original source table is not returned. |

## Example

Create an array-marked copy so json.encode serializes the value as a JSON array.

```lua theme={null}
local tags = json.array({ "api", "docs", "luau" })
local empty = json.array()

print(json.encode(tags))
print(json.encode(empty))
print(json.type(empty))
```
