I have a Python class defined as follows:
class DiscoverReply(Packet):
def __init__(self):
self.transactionId = 0
self.disklist = [];
def serialize(self):
packer = msgpack.Packer()
return packer.pack([self.transactionId,
self.id, self.disklist])
The serialized data is sent to a Java application which unpacks the data into an equivalent Java class. My class is defined as:
@Message
public class DiscoverReply extends PacketData {
private long transactionId;
private long id;
private List<Long> disklist;
...
}
The deserialization code I've written for the Python byte stream I receive in my Java app looks something like this:
MessagePack msgpack = new MessagePack();
Unpacker unpacker = msgpack.createBufferUnpacker(bytes);
DiscoverReply data = unpacker.read(DiscoverReply.class);
However, when the byte stream is processed by this code, I get an exception:
org.msgpack.MessageTypeException: org.msgpack.MessageTypeException: Unexpected raw value
The exact same code works fine if I remove the disklist member from both sides of the exchanging, leaving only simple types. It appears that the Java unpack code doesn't like the way I've packed the data on the Python side. What's the correct way to pack a Python object that contains a list. I'll probably end up with a more complex structure than even this, possibly a list of other objects and not just a list of longs. What's the correct way to serialize data in Python so that it is compatible with Java classes that have been flagged with @Message?