-
Notifications
You must be signed in to change notification settings - Fork 174
Built in serializer specifications
There are some built-in serializers in MessagePack for CLI to improve usability and interoperability. Default serializers of MessagePack for CLI respect de facto standards for some basic type representation.
You can override default behavior by registering custom serializer to the SerializationContext
explicitly.
Built-in serializers can be categolized as following:
- Primitives
- Tuples
- Known Value Objects
They behave as the Adapter between the MessagePackSerializer
API and the Packer
API. Note that the primitives in this context means "MessagePack" primitive, not CLI primitive. They are namely Boolean
, Byte
, Int16
, Int32
, Int64
, SByte
, UInt16
, UInt32
, UInt64
, Single
, Double
, and String
in the BCL types. Note that Char
, Object
, and pointers are not considered primitive.
A tuple can be considered as the strongly typed hetero-genious array, so the serializer emits an array where its length is equal to the arity.
Note that it is absolutely safe and efficient due to MessagePack
objects' strongly-typed nature.
Some value like objects in the FCL can be serialized with built-in serializer. The serializers basically use natural binary representation instead of key/value pairs because they are often embedded in the other objects.
These are the specifcation of the built-in serializers.
Be emitted as T[] which equals to the segment represented by the ArraySegment.
Be emitted as raw.
Be emitted as uint16, UTF-16 BE encoded code point.
Be emitted as Unix epoc in UTC, as uint64.
Be emitted as two length array, which the first element is a DateTime
value, and second is a int16 offset in minutes.
Be emitted as a string with format 'R'.
If the value is null, then it is emitted as nil(0xC0). Otherwise, follows the specification of T.
Be emitted as its string representation as raw (UTF-8 without BOM).
Be emitted as four length int32 array, the element is Major, Minor, Revision, Build Number, respectedly.
Be emitted as an int32 value.
Be emitted as two length array, the first element is the key property, and the second component is the value property.
Be emitted as a raw value.
Be emitted as two length double array, the first element is the real component, and the second component is the imaginary component.
Be emitted as an Unix epoc in UTC, as int64.
Be emitted as a raw (UTF-8 without BOM).