Blob.lua - binary serialization library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
Party member
Posts: 252
Joined: Sat Jul 22, 2017 7:43 pm

Blob.lua - binary serialization library

Post by grump » Tue Nov 28, 2017 5:50 pm

Blob.lua is a small LuaJIT library for binary data parsing and serialization. Its intended use is to parse and generate arbitrary binary data, and to serialize Lua tables for efficient storage or transmission.

I wrote this library mainly to implement a portable and compact file format for my font generator. You can use it to implement game saving and loading, for reading and writing all kinds of binary data formats or for efficient serialization of data over a network. It supports all basic types and nested tables, has dedicated functions to read and write native C signed/unsigned integer and floating point types, and handles both little and big endian data.

Code: Select all

local Blob = require('Blob')

local gamestate = { ... any kind of data ... }

local output = Blob()
local bin = output:string()
-- bin now contains a binary representation of gamestate that can be written to a file or sent over a network

local input = Blob(bin)
local state = input:read()
-- state now contains the data from the original gamestate table
License: MIT

Github project
API documentation

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests