textutils.unserialise

From ComputerCraft
Jump to: navigation, search

textutils.unserialise
Function
Syntax
textutils.unserialise()
Returns any
API textutils
Source CC:Tweaked (source)

Converts a serialised string to a reassembled Lua value - the opposite of textutils.serialise. Returns nil if the unserialisation failed.

textutils.unserialise is implemented using load (source). It is loaded with an empty environment, therefore strings passed to textutils.unserialise cannot cause any harm to the computer. However, they can cause an infinite loop and cause the computer to crash for failing to yield!
ExampleExampleDeserialising a serialised table
Prints a value of the given serialised table.
Code
local serialised = "{ foo = \"bar\", fruit = \"apple\", colour = \"yellow\" }"
print(textutils.unserialise(serialised).fruit)
Output
apple