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