Skip to content
yfakariya edited this page Aug 9, 2015 · 4 revisions

MessagePack is interoperable binary encoding format. You can reduce the size of stream dramatically when you have a data of which contains many binary (for example, numeric) data.

Usage

It's simple. Create, do, done.

There are only 2 steps to serialize types.

  1. Invoke MessagePackSerializer.Get<T>() where T is the type of the root object you're serialising. This returns you a MessagePackSerializer<T> object.
  2. Invoke Pack() or Unpack() on the serialiser.

A small sample is here:

[C#]

var serializer = MessagePackSerializer.Get<Foo>();
serializer.Pack(stream, foo);
stream.Position = 0;
var value = serializer.Unpack(stream);

[Visual Basic]

Dim serializer = MessagePackSerializer.Get(Of Foo)()
serializer.Pack(stream, foo)
stream.Position = 0
Dim value = serializer.Unpack(stream)

Note: Of course, you must add assembly reference to MsgPack.dll to your project.