Pkl Binary Encoding
Pkl values can be encoded into a binary format. This format is used for Pkl’s non-JVM language bindings, for example, for its Go and Swift bindings.
The binary format is uses MessagePack encoding.
Non-primitives
All non-primitive values are encoded as MessagePack arrays. The first slot of the array designates the value’s type. The remaining slots have fixed meanings depending on the type.
The array’s length is the number of slots that are filled. For example, List is encoded as an MessagePack array with two elements.
Pkl type | Slot 1 | Slot 2 | Slot 3 | Slot 4 | |||
---|---|---|---|---|---|---|---|
code |
type |
description |
type |
description |
type |
description |
|
|
Fully qualified class name |
Enclosing module URI |
Array of object members |
||||
|
Map of |
||||||
|
Map of |
||||||
|
Array of |
||||||
|
Array of |
||||||
|
Array of |
||||||
|
Duration value |
Duration unit ( |
|||||
|
Value (float64) |
DataSize unit ( |
|||||
|
|
First value |
|
Second value |
|||
|
Start |
End |
Step |
||||
|
Regex string representation |
||||||
|
|||||||
|
Object Members
Like non-primitive values, object members are encoded as MessagePack arrays, where the first slot designates the value’s type.
Member type | Slot 1 | Slot 2 | Slot 3 | ||
---|---|---|---|---|---|
code |
type |
description |
type |
description |
|
Property |
|
key |
|
property value |
|
Entry |
|
|
entry key |
|
entry value |
Element |
|
index |
|
element value |