JSON

json.isArray

Returns whether a value is treated as a JSON array by Real's JSON table detection.

Syntax

json.isArray(value: any): boolean

Arguments

NameTypeDescription
valueanyValue to inspect. Non-table values return false.

Returns

NameTypeDescription
isArraybooleantrue when the value is a table marked as a JSON array or an unmarked table with contiguous positive integer keys from 1 with its maximum index. Empty unmarked tables return false.

Description

Returns whether a value is treated as a JSON array by Real's JSON table detection.

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

Check whether a table is treated as a JSON array by Real's JSON encoder.

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

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