wire / wire-format / messagepack

MessagePack encoding (format byte + data)

MessagePack encodes each value with a leading format byte that selects a type and, for many small values, packs the value into the same byte (positive fixint 0x00-0x7F, fixstr 0xA0-0xBF, fixarray 0x90-0x9F, fixmap 0x80-0x8F). Larger values use a format byte followed by a big-endian length/value. It is a compact, self-describing tag-then-value scheme similar to CBOR.

wire-format kind wire-format status de-facto verification verified tier C wire-format@1

aka: MessagePack · msgpack · fixint · fixstr

wire format

spec: MessagePack specification

A leading format byte names the type and, for compact 'fix' forms, embeds small values directly. Strings/arrays/maps then carry a length and (for str/bin) the bytes — a self-describing tag-then-length-then-value form. MessagePack predates and heavily influenced CBOR.

fieldsizemeaning
Format byte1 byteType selector; some ranges embed the value: positive fixint 0x00-0x7F, negative fixint 0xE0-0xFF, fixmap 0x80-0x8F (low nibble = entry count), fixarray 0x90-0x9F, fixstr 0xA0-0xBF (low 5 bits = byte length).
Length / value0/1/2/4/8 bytesFor typed forms: nil 0xC0, false 0xC2, true 0xC3, uint8 0xCC, uint16 0xCD, uint32 0xCE, uint64 0xCF, str8/16/32 0xD9/0xDA/0xDB, bin8/16/32 0xC4-0xC6, array16/32 0xDC/0xDD, map16/32 0xDE/0xDF — each followed by its big-endian length or value.
Content= lengthFor str/bin: that many data bytes. For array: that many elements. For map: that many key/value pairs.

example:

A3 66 6F 6F

String "foo": 0xA3 = fixstr with length 3 (0xA0 | 3); 66 6F 6F = ASCII 'foo'.

see: wire-format/cbor-encoding


provenance

per-fact attribution:

see also

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/messagepack or /wire-format/messagepack.json