lua-users home
lua-l archive

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

On 10/11/2009 10:44, Wesley Smith wrote:
I'm sure everyone on this list has written a table serializer at some

Indeed... :-)
It is an interesting exercise, not too hard to do (apparently) although delicate to do correctly. Since everybody is showing off their serializer in this thread, I will show mine! :-D See it at: DumpObject.lua

It outputs code that can be reused as Lua code, trying to be concise when possible. It allows compact output (in one line) or indented output. It (tries to) addresses correctly cycles and most Lua types, but it is weak at handling functions (as keys or values). Otherwise, it seems quite robust for the tests I did (TestDumpObject.lua and TestDumpObject2.lua, plus some debug dumps I do in my own code).

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --