Difference between revisions of "Textutils.unserialize"
From ComputerCraft Wiki
m (Moved to CAT:APIFunctions) |
MKlegoman357 (Talk | contribs) (Updated/Improved) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=textutils.unserialize | |name=textutils.unserialize | ||
| − | |args= | + | |args={{type|string}} serializedData |
| − | |returns= | + | |returns={{type|any}} unserializedData |
|api=textutils | |api=textutils | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
| − | |desc= | + | |desc=Returns the data reassembled from string <var>serializedData</var>. Returns {{type|nil}} if unable to unserialize. Used mainly together with [[textutils.serialize]](). Also exists as textutils.unseriali'''s'''e under CC 1.6 or later. |
| + | <br/> | ||
| + | Note: the representation used by [[textutils.serialize]]() actually creates Lua-friendly syntax, so that [[loadstring]]() will also work to unserialize. See [[textutils.serialize]]() for more information. | ||
| + | |examples= | ||
| + | {{Example | ||
| + | |desc=Unserializes a table and prints a value in it. | ||
| + | |code=local serializedTable = "{value=2}" | ||
| + | local myTable = '''textutils.unserialize( serializedTable )''' | ||
| + | |||
| + | [[print]]( myTable.value ) | ||
| + | |output=2 | ||
| + | }} | ||
}} | }} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] | ||
Latest revision as of 21:17, 16 February 2015
| Returns the data reassembled from string serializedData. Returns nil if unable to unserialize. Used mainly together with textutils.serialize(). Also exists as textutils.unserialise under CC 1.6 or later.
| |
| Syntax | textutils.unserialize(string serializedData) |
| Returns | any unserializedData |
| Part of | ComputerCraft |
| API | textutils |
Examples
| Unserializes a table and prints a value in it. | |
| Code |
local serializedTable = "{value=2}"
local myTable = textutils.unserialize( serializedTable )
print( myTable.value )
|
| Output | 2 |