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.

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

Parameters

Function parameters
ParameterTypeDescription
sourceTable?Optional table to copy. Omit it to create an empty marked object.

Returns

Table

A new table carrying object metadata. Nested values are shared with the input.

Example

Example
Luau
local settings = json.object()
print(json.encode(settings)) -- {}
settings.theme = "dark"
print(json.encode(settings)) -- {"theme":"dark"}
Kawaii documentation