Skip to content

Pack/Unpack

Serialize Lua values to/from base64-encoded MessagePack. Useful for storing structured data in chip memory or transferring via non-network channels.

Usage

lua
-- Pack a Lua table to a base64 string
local packed = ic.net.pack({ x = 1, y = 2, items = {"a", "b"} })
print(type(packed))  -- "string"

-- Unpack back to a Lua value
local value = ic.net.unpack(packed)
print(value.x, value.y)  -- 1  2
print(value.items[1])     -- "a"

Supported Types

TypeSupport
nilYes
booleanYes
number (double)Yes
stringYes
table (array or map)Yes
functionNo
userdataNo
Cyclic tablesNo

Function Reference

FunctionReturnsDescription
ic.net.pack(value)stringSerialize to base64 MessagePack
ic.net.unpack(str)anyDeserialize from base64 MessagePack

⚠️ This documentation was AI-generated and may contain inaccuracies. Please submit pull requests with corrections as needed.