Open hsulei opened 8 years ago
You don't need to instantiate MessagePack object in 0.8. Please see https://github.com/msgpack/msgpack-java/blob/develop/msgpack-core/src/test/java/org/msgpack/core/example/MessagePackExample.java
How about an example of serializing a class without annotations? We used to use .register but that's no longer there.
@mtamassia for pojos check out https://github.com/msgpack/msgpack-java/tree/develop/msgpack-jackson
Thanks @marenzo. Jackson is what I ended up using, but I was wondering if it can be done without adding yet another dependency.
Thanks @marenzo .
Thanks @marenzo I spent the entire day trying to find the POJO serialization example. The code snippet at http://msgpack.org/ should be updated as it refers to an older version . Is there any reason why no one has done it yet? Can i volunteer to modify it?
+1, I spend 2 hour siting front the desk to find out a compilable demo. Can I create a PR
Took me a while to figure it out:
val packer = MessagePack.newDefaultBufferPacker();
packer.packArrayHeader(3);
packer.packLong(value.input1);
packer.packInt(value.input2);
packer.packInt(value.input3);
packer.toMessageBuffer().sliceAsByteBuffer();
This is how you can serialize a POJO with 3 fields. It is just number of values you want to pack from the class (POJO).
MessagePack msgPack =new MessagePack() ,i tried in my demo,but this constructor is private in 0.8.4 version,