msgpack / msgpack-java

MessagePack serializer implementation for Java / msgpack.org[Java]
http://msgpack.org/
Apache License 2.0
1.41k stars 321 forks source link

Java QuickStart #360

Open hsulei opened 8 years ago

hsulei commented 8 years ago

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

komamitsu commented 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

mtamassia commented 8 years ago

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

marenzo commented 8 years ago

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

mtamassia commented 8 years ago

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

hsulei commented 8 years ago

Thanks @marenzo .

dustedrob commented 8 years ago

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?

hoswey commented 7 years ago

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

lkishor commented 2 years ago

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