json. object Synchronous
Mark a shallow copy of a table as a JSON object. This keeps an empty settings record as {} and makes the intended shape clear to a consumer.
Luau
json.object(source: Table?) -> TableParameters
| Parameter | Type | Description |
|---|---|---|
source | Table? | Optional table to copy. Omit it to create an empty marked object. |
Returns
TableA new marked object table. Nested tables and other values are shared with the source.
Usage notes
The marker controls JSON shape; it does not validate that every copied key is suitable for JSON.
Example
Luau
local settings = json.object()
print(json.encode(settings)) -- {}
settings.theme = "dark"
print(json.encode(settings)) -- {"theme":"dark"}