Skip to content
This repository has been archived by the owner. It is now read-only.
Simple data serializer for Lua 5.0+
Lua
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md
README.md
serialize.lua
serialize.spec.lua

README.md

serialize.lua

Simple data serializer for Lua 5.0 and higher.

Usage

local serialize = require('serialize')
serialize({ true, "hello", 5 })

Results in:

{
    true,
    "hello",
    5,
}

Nested, indexed, associative (or both indexed and associative) tables are supported (and properly indented) as well as all primitive types. Strings are safely escaped using native string.format('%q').

You can create simple serialization to file like this:

file:write('return ' .. serialize(data))

Load serialized data by simply calling require on the file or use load (or loadstring).

Attempting to serialize a function results in an error.

See serialize.spec.lua file for more examples.

You can’t perform that action at this time.