Array
MessagePack array formats encode ordered sequences. fixarray (0x90-0x9f) handles 0-15 elements in a single prefix byte. array 16 (0xdc) and array 32 (0xdd) handle larger arrays. Elements can be any MessagePack type including nested arrays and maps.
Description
MessagePack arrays work like JSON arrays but use a count prefix instead of bracket delimiters: fixarray (0x90-0x9f): 0-15 elements. Count in lower 4 bits of prefix byte. array 16 (0xdc): 0-65535 elements. 2-byte count. array 32 (0xdd): 0-2^32-1 elements. 4-byte count.
The count is the number of elements, not bytes. Elements follow immediately after the prefix. Mixed types are allowed.
Format Variants
| Name | First Byte | Range | Description |
|---|---|---|---|
| fixarray | 0x90-0x9f | 0-15 elements | Count in lower 4 bits. Single prefix byte. |
| array 16 | 0xdc | 0-65535 elements | 2-byte big-endian count follows. |
| array 32 | 0xdd | 0-2^32-1 elements | 4-byte big-endian count follows. |
Examples
| Label | Hex | Value |
|---|---|---|
| [] | 90 | fixarray, 0 elements |
| [1,2,3] | 93 01 02 03 | fixarray, 3 elements |
| [[1,2],[3]] | 92 92 01 02 91 03 | nested arrays |