The BOS data format is kept simple. All serialized data begins with
4-bytes that specify the total size of the data. The size is used to
verify that all data is present. Following this the DataType
followed
by type specific data.
Field |
Size (bytes) |
Description |
DataSize |
4 |
The total size of the data including the DataSize bytes |
RootValue |
* |
Depending on the DataType, the root value may have child values. Data size is dependant on the DataType of the value. |
The data type specifies what type of data is serialized and is always the first byte of a serialized value.
The fields used to serialize a value differ for each data type.
Type |
Value |
Notes |
NULL |
0x00 |
No data - deserializes as null |
BOOL |
0x01 |
|
INT8 |
0x02 |
Signed byte |
INT16 |
0x03 |
Signed 16-bit integer |
INT32 |
0x04 |
Signed 32-but integer |
INT64 |
0x05 |
Not implemented. Included for future use. |
UINT8 |
0x06 |
Unsigned byte |
UINT16 |
0x07 |
Unsigned 16-bit integer |
UINT32 |
0x08 |
Unsigned 32-bit integer |
UINT64 |
0x09 |
Not implemented. Included for future use. |
FLOAT |
0x0A |
32-bit floating point number. |
DOUBLE |
0x0B |
Not implemented. Included for future use. |
STRING |
0x0C |
String of characters. |
BYTES |
0x0D |
Binary data. |
ARRAY |
0x0E |
Array of Values. |
OBJ |
0x0F |
JSON-like object with named key values. |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies NULL |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies BOOL |
Value |
1 |
Value is 0x01 if true , 0x00 if false |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies INT8 |
Value |
1 |
The 8-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies INT16 |
Value |
2 |
The 16-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies INT32 |
Value |
4 |
The 32-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies UINT8 |
Value |
1 |
The unsigned 8-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies UINT16 |
Value |
2 |
The unsigned 16-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies INT32 |
Value |
4 |
The unsigned 32-bit integer value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies FLOAT |
Value |
4 |
The 32-bit floating point value |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies STRING |
Length |
Variable |
The UVarInt specifying the number of bytes in the string |
Value |
* |
The string value. The size is the number of bytes specified in Length field |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies BYTES |
Length |
Variable |
The UVarInt specifying the number of bytes |
Value |
* |
The bytes. The number of bytes is specified in Length field |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies ARRAY |
Count |
Variable |
The UVarInt specifying how many Values are in the Values field. |
Values |
* |
The serialized Values that are in the array. |
Field |
Size (bytes) |
Description |
DataType |
1 |
Data type that specifies OBJ |
KeyCount |
Variable |
The UVarInt specifying how many key/values in the KeyValues field. |
KeyValues |
* |
The key/value pairs of the object. See KeyValue. |
Field |
Size (bytes) |
Description |
KeyNameLength |
Variable |
The UVarInt integer specifying the number of bytes used for the key name. |
KeyName |
* |
The UTF8 encoded key name string. The number of bytes is specified with KeyNameLength |
Value |
* |
The serialized Value. Fields and size of Value depend on the Value's DataType. |
This is not an available Value type but is used within Value fields to
specify lengths and counts. It is based on the Variable Length Integer used in Bitcoin.
Number |
Size (bytes) |
Format |
< 0xFD |
1 |
8-bit unsigned integer |
<= 0xFFFF |
3 |
0xFD followed by the number as 16-bit unsigned integer |
<= 0xFFFF FFFF |
5 |
0xFE followed by the number as 32-bit unsigned integer |
- |
9 |
Not Implemented. 0xFF followed by the number as 64-bit unsigned integer |