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.
Luau
json.array(source: Table?) -> TableParameters
| Parameter | Type | Description |
|---|---|---|
source | Table? | Optional table whose sequence entries, 1 through #source, are copied into the marked result. |
Returns
TableA 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
Luau
local tags = json.array()
print(json.encode(tags)) -- []
table.insert(tags, "featured")
print(json.encode(tags)) -- ["featured"]