JSON

json.isArray

Returns whether a value is marked or shaped as a JSON array.

Syntax

json.isArray(value: any): boolean

Arguments

NameTypeDescription
valueanyNew value to write.

Returns

NameTypeDescription
isArraybooleanTrue when the value is treated as a JSON array.

Description

Returns whether a value is marked or shaped as a JSON array.

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

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

Example

Distinguish JSON arrays from JSON objects.

local items = json.array({ "one", "two" })
local record = json.object({ name = "Real" })

print(json.isArray(items))
print(json.isArray(record))