json.array Synchronous

Mark a new table as a JSON array, especially when the array may be empty. The marker prevents an empty list from turning into {} when it is encoded.

Syntax
Luau
json.array(source: Table?) -> Table

Parameters

Function parameters
ParameterTypeDescription
sourceTable?Optional table whose sequence entries, 1 through #source, are copied into the marked result.

Returns

Table

A new marked array. Named keys are left out, and nested values are shared rather than deeply copied.

Usage notes

Use json.object for a record with named fields. The array marker remains with this table as items are added.

Example

Example
Luau
local tags = json.array()
print(json.encode(tags)) -- []
table.insert(tags, "featured")
print(json.encode(tags)) -- ["featured"]
Kawaii documentation