Load a table from serialized text (table.load_string)
Declaration
tab = table.load_string(text)
Parameters
- text
String. Serialized textual description of a table's tree structure. Must contain only static data, no executable code.
Returns
- tab
Table or nil. Returns the loaded table on success; nil on failure.
Notes
Convert a tree-structure textual description to a table object.
In a sense, table.load_string is the inverse of table.deep_dump (depending on cyclic references and non-table reference types).
Unlike load, this does not execute any code in the text; only static data are used.
For example, the following contains odd code; the result is b = nil.
b = table.load_string[[ {
a = os.execute('reboot'), -- This code will NOT run and will become nil
} ]]
Example
local t = table.load_string[[ {
a = 1,
b = 2,
c = 3,
} ]]
sys.alert(t.b)
Note: Uses sys.alert