Syntax
json.array(source: table): tableArguments
| Name | Type | Description |
|---|---|---|
source | table | Source value used by the operation. |
Returns
| Name | Type | Description |
|---|---|---|
array | table | Table marked for JSON array encoding. |
Description
Marks a table as a JSON array so encoding keeps array semantics, including for empty tables.
Call it with 1 parameter(s): source. The argument table explains which values are required and which ones only refine the behavior.
It returns array (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Mark a table as a JSON array, including when it is empty.
local tags = json.array({ "api", "docs", "luau" })
local empty = json.array()
print(json.encode(tags))
print(json.encode(empty))