The json module is used to decode and encode data in JSON-format (Javascript Object Notation).
Decode JSON-encoded data. The optional argument ’nullHandling’ specifies how JSON-null values are mapped to Lua values.
-
’json-null’ (the default) maps to a Lua table with a special ’JSON-null’-Metatable that can be detected using the isnull() function described below.
-
’empty-string’ maps JSON-null values to an empty string, which can be useful in web-based applications where e.g. PostgreSQL is used to generate JSONndata which is then handed to a browser over a WebSocket or similar mechanism.
-
’nil’ maps JSON-null values to Lua nil.
decode() returns the decoded values as Lua values or nil if an error occurs. If an error occured, a second return value contains the error message.