Type System
LODE supports four primitive types. There are no nested structures, unions, or user-defined types.
Primitive Types
string
UTF-8 encoded text. No length limit beyond the 16-bit length prefix (max 65,535 bytes per field).
Type tag: 0x01
{ "id": 1, "name": "title", "type": "string", "required": true }bool
A single byte: 0x01 for true, 0x00 for false.
Type tag: 0x02
{ "id": 2, "name": "enabled", "type": "bool", "required": true }string[]
An ordered array of UTF-8 strings. Encoded as a count followed by length-prefixed items.
Type tag: 0x10
{ "id": 3, "name": "tags", "type": "string[]", "required": true }Wire format:
count (2 bytes, big-endian)
item_length (2 bytes) + item_bytes
item_length (2 bytes) + item_bytes
...map<string,string>
A key-value map where both keys and values are UTF-8 strings. Keys are always sorted lexicographically before encoding.
Type tag: 0x20
{ "id": 4, "name": "metadata", "type": "map<string,string>", "required": false }Wire format:
count (2 bytes, big-endian)
key_length (2 bytes) + key_bytes + value_length (2 bytes) + value_bytes
key_length (2 bytes) + key_bytes + value_length (2 bytes) + value_bytes
...Type Tag Registry
| Type | Tag (hex) | Tag (decimal) |
|---|---|---|
string | 0x01 | 1 |
bool | 0x02 | 2 |
string[] | 0x10 | 16 |
map<string,string> | 0x20 | 32 |
Tags 0x03–0x0F, 0x11–0x1F, and 0x21–0xFF are reserved for future types.
Type Coercion
LODE performs no implicit type coercion. If a schema declares a field as string and the source value is a number, the encoder throws:
Error: Field "port" expected string, got numberMap values are coerced to strings via String() — this is the only coercion in the system.
Required vs Optional
Fields default to required: true if the required property is omitted from the schema.
- Required fields must be present in the source object, or
compilethrows - Required fields must be present in the Vein binary, or
decodethrows - Optional fields (
required: false) are silently omitted from the binary ifundefinedornull