json.keys Synchronous

Collect the keys of a table into an array. This helps when presenting a list of available settings or inspecting an object with fields chosen at runtime.

Syntax
Luau
json.keys(value: Table) -> {any}

Parameters

Function parameters
ParameterTypeDescription
valueTableTable whose keys should be collected.

Returns

{any}

An array containing the keys in table iteration order.

Usage notes

Iteration order is not a stable display order. Sort the result when people need a predictable list.

Example

Example
Luau
local keys = json.keys({ theme = "dark", volume = 0.5 })
table.sort(keys)
for _, key in ipairs(keys) do print(key) end
Kawaii documentation