Nil and Boolean
MessagePack nil (null), false, and true each encode as a single byte. nil = 0xc0, false = 0xc2, true = 0xc3. No additional bytes follow. These are the simplest MessagePack formats.
Description
nil, false, and true are single-byte values in MessagePack. Each is represented by a unique byte with no additional data: 0xc0 = nil (null) 0xc2 = false 0xc3 = true
Note that 0xc1 is reserved (never-used byte). This single-byte encoding makes nil and boolean values cheaper than in JSON where 'null' is 4 bytes, 'true' is 4 bytes, and 'false' is 5 bytes.
Format Variants
| Name | First Byte | Range | Description |
|---|---|---|---|
| nil | 0xc0 | N/A | Null/nil. Single byte, no data follows. |
| false | 0xc2 | N/A | Boolean false. Single byte. |
| true | 0xc3 | N/A | Boolean true. Single byte. |
Examples
| Label | Hex | Value |
|---|---|---|
| nil | c0 | null |
| false | c2 | false |
| true | c3 | true |