I want to use MsgPack instead of Newtonsoft.JSON as it is much faster but I have an issue when trying to deserialize a list of nullable integer.
Here is a snippet of the code I am using:
public class MyClass
{
public MyClass()
{
MyCustomList = new List<int?>();
}
public List<int?> MyCustomList { get; private set; }
}
MyClass source = new MyClass();
source.MyCustomList.Add(1);
source.MyCustomList.Add(null);
var context = new SerializationContext {SerializationMethod = SerializationMethod.Map};
context.DictionarySerlaizationOptions.OmitNullEntry = true;
//Create serializers
var serializer = SerializationContext.Default.GetSerializer<MyClass>(context);
var serializerDest = SerializationContext.Default.GetSerializer<MyClass>(context);
Stream stream = new MemoryStream();
serializer.Pack(stream, source);
stream.Position = 0;
var unpackedObject = serializerDest.Unpack(stream);
The last line of code is throwing an exception like "{"The unpacked value is not 'System.Int32' type. Do not convert nil MessagePackObject to System.Int32."}"
My 'MyCustomList' property is of type List and does not work. If I switched to IList it works
Any idea if this is a known error? How can I get rid of it?
Thanks