Code Monkey home page Code Monkey logo

lua_table_serializer's Introduction

-- Lua table serializer

details = {
  intention = 'Serialize data to machine-and-human readable format.',
  requirements = {'Lua 5.3'},
  license = 'GPLv3',
  priorities = {
    fast = 0,
    simple = 0.4,
    flexible = 0.6,
  },
  handles = {
    cycles = true,
    metatables = false,
    threads = false,
    userdata = false,
    functions = false,
  },
  installation = {
    '$ git clone https://github.com/martin-eden/lua_table_serializer',
    '$ cd lua_table_serializer',
  },
  usage =
    function(t)
      t = t or _G
      require('workshop.base')
      local table_to_str = request('!.formats.lua_table_code.save')
      print(table_to_str(t))
    end,

  additional_modes = {
    minimal = {
      intention = 'Serialize table data without whitespaces.',
      usage =
        function(t)
          t = t or _G
          --[[
            1. Clone <lua_table.save.interface> object.
            2. Override <install_node_handlers> function in it.
            3. Provide changed object to generic table serializer, <.c_table_serializer>.
          ]]
          -- (1)
          local terser = new(request('!.formats.lua_table.save.interface'))
          -- (2)
          terser.install_node_handlers =
            request('!.formats.lua_table.save.install_node_handlers.minimal')
          -- (3)
          local table_to_str_orig = request('!.formats.lua_table_code.save')
          local table_to_str =
            function(t)
              return table_to_str_orig(t, {c_table_serializer = terser})
            end
          -- test
          print(table_to_str(t))
        end,
    },
  },
}

lua_table_serializer's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.