Difference between revisions of "Textutils.serialize"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) (Updated/Improved) |
m (Fix bug in code example) |
||
Line 14: | Line 14: | ||
|code=local myTable = { | |code=local myTable = { | ||
key = "value", | key = "value", | ||
− | [5] = | + | [5] = "numbers", |
array = {1, 2, 3} | array = {1, 2, 3} | ||
} | } | ||
Line 22: | Line 22: | ||
{ | { | ||
key = "value", | key = "value", | ||
− | [5] = | + | [5] = "numbers", |
array = { | array = { | ||
1, | 1, |
Latest revision as of 14:57, 28 July 2016
Function textutils.serialize | |
Converts the object to a string that can be saved in a file or sent over rednet and then converted back into a copy of the object later, using textutils.unserialize(). Nested structures are supported, but tables with circular graphs will be detected and raise an error.
| |
Syntax | textutils.serialize(table/string/number/boolean/nil data) |
Returns | string serializedData |
Part of | ComputerCraft |
API | textutils |
Examples
Example | |
Serializes a table and prints it | |
Code |
local myTable = { key = "value", [5] = "numbers", array = {1, 2, 3} } print( textutils.serialize( myTable ) ) |
Output |
{ key = "value", [5] = "numbers", array = { 1, 2, 3 } } |