Skip to main content

isNull

Returns true if the value specified is a null read from a json.

Parameters

Parameter NameParameter TypeParameter Description
valobjectThe JSON value to check if it is null

The following example prints "[value] is null!" if any item in the converted json (see json.parse(string) for more information) is null

local jsonString = "\"{\"one\": 1, \"two\": null, \"three\": \"3\"}\""
local j = json.parse(jsonString)
for _, k in pairs(j) do
if json.isNull(k) then
-- don't forget to cast the value to a string!
print(tostring(k).." is null!")
end
end