Skip to content

martin-eden/lua_table_serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepWiki (sometimes AI explains it better)

What

Created Updated Size License
2017-05 2026-06 < 50 K LGPL3

Serialize data in Lua table to string with Lua code that recreates this data.

Lua tables can contain cross-references, so actually it's graph encoder to Lua code.

Usage scenarios

I'm using it as data exploration tool. Also it's very handy at debugging Lua code.

First run

t2s = require('serialize_lua_graph')
print(t2s(_G))

Encoding options

Options is optional table that can be passed as second argument to function. That's Lua table with values like { style = 'readable_short' }.

We'll demonstrate behavior on excerpt of _G table printout.

Serializer function supports three encoding styles: minimal, readable_short and readable_long.

style Output
minimal local T_1={bit32={arshift='function: 0x557703aab060',
readable_short local T_1 = { bit32 = { arshift = 'function: 0x55da5d825060',
readable_long local T_1 = {
bit32 = {
arshift = 'function: 0x5595744ae060',

Serializer function supports three behavior flags:

Behavior flag Output
☑ use_compact_indices package = T_2,
☐ use_compact_indices ['package'] = T_2,
☑ use_compact_sequences searchers = { 'function: 0x56089fbeba20'
☐ use_compact_sequences searchers = { [1] = 'function: 0x5580fdeb8a20'
☑ omit_tail_delimiter xpcall = 'function: 0x5612c12e1e90' }
☐ omit_tail_delimiter xpcall = 'function: 0x55b2598d9e90', }

Requirements

  • Lua 5.3 (or 5.4, 5.5)

Install/remove

  • Save file serialize_lua_graph.lua from deploy/
  • Place it to your Lua workplace for require()

Modify

  • Clone repo
  • Modify files in src/

Rebuild

See also

About

Serialize lua table (even with cycles) to lua code that reconstructs it.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors