Library of Functions


Description


Converts a JSON string into a Lua table.
 
Scope
This function is only defined in the scope of a virtual device.  It will not work in a scene.

Usage and Arguments


json.decode(json_string)

  • json_string (string) – JSON string to decode.

Returned Values


table: A decoded Lua table representing the original JSON string.

Examples


jsonTable = { value1 = 512, value2 = json.null }
jsonString = json.encode(jsonTable)
 
-- after encoding jsonString variable contains '{ "value2": null, "value1": 512 }' string
fibaro:debug(jsonString)
 
-- null will be decoded to json.null value
jsonTable = json.decode(jsonString)
if(jsonTable.value2 == json.null)
then
  fibaro:debug('null value successfully decoded')
end

See Also


json.encode
json.null