NULL constant in JSON (json.null)
Declaration
json.null
Description
This is not a function, but a constant. When printed as text it appears like "
userdata: 0x0".
It represents the JSONnullvalue.
Why is it necessary? Becausenilin a Lua table means absence; when encoding to JSON, a key withnildisappears. 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