system.serialization
The serialization module provides functions for serializing and deserializing objects in multiple formats, as well as some miscellaneous encoding types.
serialization.base64
serialization.base64.encode(str: string): string
Encodes a binary string into Base64.
Arguments
str
: The string to encode
Return Values
The string’s representation in Base64
serialization.base64.decode(str: string): string
Decodes a Base64 string to binary.
Arguments
str
: The Base64 to decode
Return Values
The decoded data
serialization.json
serialization.json.encode(val: any): string
Serializes an arbitrary Lua object into a JSON string.
Arguments
val
: The value to encode
Return Values
The JSON representation of the object
serialization.json.decode(str: string): any
Parses a JSON string and returns a Lua value represented by the string.
Arguments
str
: The JSON string to decode
Return Values
The Lua value from the JSON
serialization.json.save(val: any, path: string)
Saves a Lua value to a JSON file.
Arguments
val
: The value to savepath
: The path to the file to save
Return Values
This function does not return anything.
serialization.json.load(path: string): any
Loads a JSON file into a Lua value.
Arguments
path
: The path to the file to load
Return Values
The loaded value
serialization.lua
serialization.lua.encode(val: any, opts: {minified=boolean,allow_functions=boolean}?): string
Serializes an arbitrary Lua object into a serialized Lua string.
Arguments
val
: The value to encodeopts
: Any options to specify while encoding (optional)
Return Values
The serialized Lua representation of the object
serialization.lua.decode(str: string, opts: {allow_functions=boolean}?): any
Parses a serialized Lua string and returns a Lua value represented by the string.
Arguments
str
: The serialized Lua string to decodeopts
: Any options to specify while decoding (optional)
Return Values
The Lua value from the serialized Lua
serialization.lua.save(val: any, path: string, opts: {minified=boolean,allow_functions=boolean}?)
Saves a Lua value to a serialized Lua file.
Arguments
val
: The value to savepath
: The path to the file to saveopts
: Any options to specify while encoding (optional)
Return Values
This function does not return anything.
serialization.lua.load(path: string, opts: {allow_functions=boolean}?): any
Loads a serialized Lua file into a Lua value.
Arguments
path
: The path to the file to loadopts
: Any options to specify while decoding (optional)
Return Values
The loaded value
serialization.toml
serialization.toml.encode(tbl: table, opts: {indent=boolean}?): string
Encodes a table into TOML format. This table must only have integer or string keys in itself and each subtable, and cannot mix strings and ints.
Arguments
tbl
: The table to encodeopts
: Any options to specify while encoding (optional)
Return Values
The encoded TOML data
serialization.toml.decode(str: string, opts: table?): table
Parses TOML data into a table.
Arguments
str
: The TOML data to decodeopts
: Options (none available in this version) (optional)
Return Values
A table representing the TOML data
serialization.toml.save(val: table, path: string, opts: {indent=boolean}?)
Saves a table to a TOML file.
Arguments
val
: The value to savepath
: The path to the file to saveopts
: Any options to specify while encoding (optional)
Return Values
This function does not return anything.
serialization.toml.load(path: string, opts: table?): table
Loads a TOML file into a table.
Arguments
path
: The path to the file to loadopts
: Options (none available in this version) (optional)
Return Values
The loaded value