1

I am using the MessagePack for CLI (https://github.com/msgpack/msgpack-cli) library and I am wondering, if it's possible to disable the integer compression.

For example:

// The following collection
object[] { (Int32)10, (Int32)100, (Int32)1000 };
// will look like this after unpacking
MessagePackObject[] { (Byte)10, (Byte)100, (Int16)1000 }

This forces me to explicitly convert each item of the collection in order to cast it back to int[], which is quite time consuming.

Filip Minx
  • 2,438
  • 1
  • 17
  • 32

1 Answers1

1

Use directly fixed-sized types:

msgpack::sbuffer buffer;
msgpack::packer<msgpack::sbuffer> pk(&buffer); 

msgpack::type::fix_uint32 code(0x00);
msgpack::type::fix_uint32 type(123);

pk.pack(code);
pk.pack(type);
o2gy
  • 333
  • 1
  • 13
  • Actually my question was directed specifically on the C# implementation of messagepack (https://github.com/msgpack/msgpack-cli). I still cannot find any way to force the serializer to not compress the integers. – Filip Minx Oct 21 '16 at 12:33
  • Sorry. Maybe something like this would be useful? `packer.Pack`. It is from `msgpack-cli/blob/master/test/MsgPack.UnitTest/PackerTest.PackT.cs`. I'm pretty sure that somewhere there is a suitable example in the `test` folder :) – o2gy Oct 21 '16 at 12:53