JSON

json.values

Returns the direct values from a table in a new JSON array table.

Syntax

json.values(object: table): table

Arguments

NameTypeDescription
objecttableTable to enumerate. The function checks this argument with type checking.

Returns

NameTypeDescription
valuestableNew array-style table containing the direct values from the input table. The output is marked as a JSON array. Enumeration uses table iteration, so no ordering guarantee is visible in the function.

Description

Returns the direct values from a table in a new JSON array table. JSON metadata entries are not included.

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

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

Example

Collect the direct values from a table into a JSON array-marked table.

local list = json.array({ "one", "two" })

for _, value in ipairs(json.values(list)) do
    print(value)
end