Leopard is the fastest serializer for Lua 5.1.
- Function support.
- Automatically escapes strings.
- Simple and easy use.
- Custom config support.
- Human readable output.
- Table compression.
Test can be found in tests/test.lua.
- leopard (10000): 0.72s
- serpent (10000): 1.646s
- Rochet2 (10000): 3.775s
This function serializes table tbl
and returns a string.
<string> Serialize(<table tbl>);
This function serializes and compresses table tbl
and returns a string.
<string> SerializeCompress(<table tbl>);
This function iterates through the passed arguments, formatting each value, then returns each value joined by ,
.
<string> FormatArguments(<... any>);
This function formats string str
.
<string> FormatString(<string str>);
This function allows you to edit the configuration used by the serializer
<void> UpdateConfig(<table { spaces = 4 }>);
local Serializer = require("leopard");
local function test(a, b, ...)
print(a,b, ...);
end;
local Target = {
1,
true,
test,
"Hello World \7"
}
local Output = Serializer.Serialize(Target);
print(Output);
{
1,
true,
function(...) return loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\12\0\0\0\64\46\92\116\101\115\116\46\108\117\97\0\2\0\0\0\4\0\0\0\0\2\3\7\6\0\0\0\197\0\0\0\0\1\0\0\64\1\128\0\165\1\0\0\220\64\0\0\30\0\128\0\1\0\0\0\4\6\0\0\0\112\114\105\110\116\0\0\0\0\0\6\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\4\0\0\0\3\0\0\0\2\0\0\0\97\0\0\0\0\0\5\0\0\0\2\0\0\0\98\0\0\0\0\0\5\0\0\0\4\0\0\0\97\114\103\0\0\0\0\0\5\0\0\0\0\0\0\0")(...); end,
"Hello World \7"
}
local Serializer = require("leopard");
local function test(a, b, ...)
print(a,b, ...);
end;
local Target = {
1,
true,
test,
"Hello World \7"
}
local Output = Serializer.SerializeCompress(Target);
print(Output);
{1,true,function(...) return loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\12\0\0\0\64\46\92\116\101\115\116\46\108\117\97\0\2\0\0\0\4\0\0\0\0\2\3\7\6\0\0\0\197\0\0\0\0\1\0\0\64\1\128\0\165\1\0\0\220\64\0\0\30\0\128\0\1\0\0\0\4\6\0\0\0\112\114\105\110\116\0\0\0\0\0\6\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\4\0\0\0\3\0\0\0\2\0\0\0\97\0\0\0\0\0\5\0\0\0\2\0\0\0\98\0\0\0\0\0\5\0\0\0\4\0\0\0\97\114\103\0\0\0\0\0\5\0\0\0\0\0\0\0")(...); end,"Hello World \7"}