-
Notifications
You must be signed in to change notification settings - Fork 192
Text API
This library allows to work with text data in different ways: to serialize/deserialize tables, to wrap and limit strings, to obtain Braille font chars or to search data in UTF-8 format.
Serializes given table to a string.
If pretty argument is passed then serialization result will be more human-readable, by default it's set to false. Notice that pretty argument performs several additional checks on the type of keys and table values, and also generates the line break after each value. Therefore, use it only if the readability of the result is in priority over performance.
The recursionDepth argument is responsible to depth of sub-table serialization calls, by default it's set to infinity. Finally, the indentator argument represents a string which will be used for indentation in pretty mode, by default it's set to " ". Here is example of serialization:
local myTable = {
"Hello",
"world",
abc = 123,
def = "456",
ghi = {
jkl = true,
}
}
table.serialize(myTable)
table.serialize(myTable, true)> {[1]="Hello",[2]="world",["abc"]=123,["def"]="456",["ghi"]={["jkl"]=true}}
> {
"Hello",
"world",
abc = 123,
def = "456",
ghi = {
jkl = true,
}
}Deserializes string representation of Lua table and returns result. Returns table result on success, nil and reason message otherwise:
table.deserialize("{ abc = 123 }")> {
abc = 123
}