NULL constant in JSON (json.null)
Declaration
json.null
Notes
This is not a function, but a constant. When printed as text it appears like "
userdata: 0x0
".
It represents the JSONnull
value.
Why is it necessary? Becausenil
in a Lua table means absence; when encoding to JSON, a key withnil
disappears. A specific sentinel is needed to represent JSONnull
.
This value can be used in XUI.
Example
local tb = json.decode('{"nullvalue":null}')
if tb['nullvalue'] == json.null then
sys.alert(json.null)
end
Note: Uses sys.alert