Syntax
json.object(source: table): tableArguments
| Name | Type | Description |
|---|---|---|
source | table | Source value used by the operation. |
Returns
| Name | Type | Description |
|---|---|---|
object | table | Created drawing object. |
Description
Marks a table as a JSON object so encoding keeps object semantics.
Call it with 1 parameter(s): source. The argument table explains which values are required and which ones only refine the behavior.
It returns object (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Mark a table as a JSON object, including when it is empty.
local profile = json.object({
name = "Guest",
active = true,
})
local empty = json.object()
print(json.encode(profile))
print(json.encode(empty))