JSON

json.isNull

Returns whether a value is Real's JSON null sentinel, json.null.

Syntax

json.isNull(value: any): boolean

Arguments

NameTypeDescription
valueanyValue to inspect. Only the json.null value returns true; Lua nil and other values return false.

Returns

NameTypeDescription
isNullbooleantrue when the value is the exact json.null sentinel, otherwise false.

Description

Returns whether a value is Real's JSON null sentinel, json.null.

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

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

Example

Check whether a value is the json.null sentinel instead of Lua nil.

local value = json.decode("null")

if json.isNull(value) then
    print("The value is JSON null")
end

print(json.isNull(nil))