kmj-json
The kmj-json package provides a JSON codec.
decode
The decode field contains a function for decoding a JSON encoded type.
Syntax
decode(input: string): (output: any)
Arguments
The first argument should contain the JSON encoded representation of a type.
Returns
The first return value will be the decoded Lua equivalent value type of the given JSON, or nil if the input could not be interpreted successfully.
encode
The encode field contains a function for encoding a Lua value into a JSON encoded type.
Syntax
encode(input: any): (output: string|nil)
Arguments
The first argument should contain the Lua value that should be JSON encoded. Accepted Lua types are nil, boolean, number, string and table.
Returns
The first return value will be the JSON encoded representation of the given input, or a Lua nil if an unsupported value such as function, userdata or thread was given.