[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table output
- From: Philippe Lhoste <PhiLho@...>
- Date: Wed, 11 Nov 2009 12:12:47 +0100
On 10/11/2009 10:44, Wesley Smith wrote:
I'm sure everyone on this list has written a table serializer at some
point.
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
http://bazaar.launchpad.net/%7Ephilho/%2Bjunk/Lua/annotate/head%3A/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).
http://bazaar.launchpad.net/%7Ephilho/%2Bjunk/Lua/annotate/head%3A/TestDumpObject.lua
http://bazaar.launchpad.net/%7Ephilho/%2Bjunk/Lua/annotate/head%3A/TestDumpObject2.lua
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --