json. object Synchronous
Create a shallow copy of a table and mark it for JSON object encoding. Use it to make an empty object serialize as {}. Use the marker for a dictionary or settings record whose empty form must remain an object.
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 table carrying object metadata. Nested values are shared with the input.
Example
Luau
local settings = json.object()
print(json.encode(settings)) -- {}
settings.theme = "dark"
print(json.encode(settings)) -- {"theme":"dark"}