codec/cbor
lib/codec/cbor.vklib/codec/cbor.vk Pure-Veko RFC 8949 CBOR deterministic encoder and decoder. Supports major types 0..5 and 7 (bool, .null, IEEE-754 f64) with canonically sorted map keys. Zero capabilities required.
encode = fn [v any] bytes
Encodes a Veko value into deterministic RFC 8949 CBOR bytes.
Executable Example
use [cbor = codec/cbor]
raw = cbor/encode { count = -100, ok = true, empty = .null, tag = 'veko' }
dec = cbor/decode raw
if (map/get dec 'count') != -100 or (map/get dec 'empty') != .null or (map/get dec 'tag') != 'veko' [
err 'cbor roundtrip'
] else [ .ok ]
decode = fn [data bytes] any
Decodes RFC 8949 CBOR bytes into a Veko value (CBOR null maps to .null).