JSON

json.keys

Returns the keys of a JSON object as an array table.

Syntax

json.keys(object: table): table

Arguments

NameTypeDescription
objecttableObject, table, or drawing value to inspect or change.

Returns

NameTypeDescription
keystableArray table containing object keys.

Description

Returns the keys of a JSON object as an array table.

Call it with 1 parameter(s): object. The argument table explains which values are required and which ones only refine the behavior.

It returns keys (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Collect an object's keys into a JSON array.

local record = {
    name = "Real",
    enabled = true,
}

for _, key in ipairs(json.keys(record)) do
    print(key)
end