Skip to Content
DocsLanguageType System

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

TypeTag (hex)Tag (decimal)
string0x011
bool0x022
string[]0x1016
map<string,string>0x2032

Tags 0x030x0F, 0x110x1F, and 0x210xFF 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 number

Map 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 compile throws
  • Required fields must be present in the Vein binary, or decode throws
  • Optional fields (required: false) are silently omitted from the binary if undefined or null
Last updated on