local pp = require'pp'
Fast, compact serialization producing portable Lua source code.
int64_t
and uint64_t
types.__pwrite
metamethod.\n
and \r
protects binary integrity when opening in text mode.\0
and \t
protects binary integrity with code editors.pp.print(v1,...)
pp(v1, ...)
Pretty-print the arguments to standard output. Cycle detection and indentation are enabled. Unserializable values get a comment in place.
pp.write(write, v, [, indent][, parents][, quote][, onerror])
Pretty-print a value using a supplied write function that takes a string. The other arguments are:
indent
- enable indentation eg. '\t'
indents by one tab (default is compact output with no whitespace)parents
- enable cycle detection eg. {}
quote
- change string quoting eg. '"'
(default is "'")onerror
- enable error handling eg. function(err_type, v, depth) error(err_type..': '..tostring(v)) end
Example:
local function chunks(t)
return coroutine.wrap(function()
return pp.write(coroutine.yield, t)
end)
end
for s in chunks(t) do
socket:send(s)
end
pp.save(file, v[, indent][, parents][, quote][, onerror])
Pretty-print a value to a file.
pp.format(v[, indent][, parents][, quote][, onerror]) -> s
Pretty-print a value to a string.