Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 825 Bytes

cbor.md

File metadata and controls

28 lines (20 loc) · 825 Bytes

cbor: pure Lua implementation of the CBOR

local cbor = require "cbor"

The cbor package is taken from Lua-CBOR.

Lua-CBOR is a (mostly) pure Lua implementation of the CBOR, a compact data serialization format, defined in RFC 7049.

Please check Lua-CBOR for further information.

LuaX applies a patch to cbor to specify the key order with a function overloading pairs. If the pairs parameter is a function, it is used to iterate over tables instead of the standard pairs function.

E.g.:

local t = {x=1, y=2, z=3}
local sorted = cbor.encode(t, {pairs=F.pairs})

-- sorted is a CBOR string where fields in all tables are ordered according to F.pairs