msgpack-java icon indicating copy to clipboard operation
msgpack-java copied to clipboard

Java QuickStart

Open hsulei opened this issue 8 years ago • 8 comments

MessagePack msgPack =new MessagePack() ,i tried in my demo,but this constructor is private in 0.8.4 version,

hsulei avatar Apr 11 '16 02:04 hsulei

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

komamitsu avatar Apr 30 '16 14:04 komamitsu

How about an example of serializing a class without annotations? We used to use .register but that's no longer there.

mtamassia avatar May 04 '16 17:05 mtamassia

@mtamassia for pojos check out https://github.com/msgpack/msgpack-java/tree/develop/msgpack-jackson

marenzo avatar May 04 '16 20:05 marenzo

Thanks @marenzo. Jackson is what I ended up using, but I was wondering if it can be done without adding yet another dependency.

mtamassia avatar May 04 '16 21:05 mtamassia

Thanks @marenzo .

hsulei avatar May 21 '16 00:05 hsulei

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?

dustedrob avatar May 25 '16 21:05 dustedrob

+1, I spend 2 hour siting front the desk to find out a compilable demo. Can I create a PR

hoswey avatar Feb 08 '17 02:02 hoswey

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).

lkishor avatar Mar 03 '22 15:03 lkishor