lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Nov 10, 2009 at 12:44, Wesley Smith <wesley.hoke@gmail.com> wrote:
> I'm sure everyone on this list has written a table serializer at some
> point.  Here's mine:
> http://www.mat.ucsb.edu/projects/luaAV/browser/trunk/extra/modules/serializer/init.lua

And here are ours (from not-yet-released Lua library lua-nucleo):

-- tstr to print data to user (does not support recursive tables,
"corrupts" non-serializable types by converting them to human-readable
string)

http://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/tstr.lua

-- tserialize to serialize data for computer consumption. It is less
readable, relatively slower, but supports recursive tables

http://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/tserialize.lua

If you need multiline output, we have tpretty() in the works... but it
is not ready yet. :-)

These implementations are quite fast (at least according to my humble
benchmarks). If you see faster pure-Lua serializer / dumper with
comparable features, please tell me :-)

Alexander.