Capy-Bearer Documentation

brb_decode

lib call

Capy

function brb_decode(encoded : string) any

Description

brb_decode decodes BRRB data into an any value.

Use it to read binary data from brb_encode. Strings can contain zero bytes. Signed and unsigned 64-bit integers keep their exact values and kinds. Map insertion order survives, but shared object identities do not.

Invalid input returns a failure. Valid encoded empty strings succeed with value: "". Encoded none succeeds with value: none.

The decoder requires one complete BRRB version 2 document with no trailing bytes. It rejects malformed lengths, unknown tags, nonfinite numbers, and truncated input. Limits are 64 value levels and 262,144 nodes, including the root. See brb_encode for the byte layout.

Parameters

encoded : BRRB data

Return Values

{ok: true, value: ...} on success, or {ok: false, error: "..."} on failure. The value field contains the decoded value.

Example

Capy

var value := brb_decode(brb_encode({"name": "Ada"})).value
print(value["name"], "\n")

Output

Ada