<dependency>
<groupId>org.msgpack</groupId>
<artifactId>msgpack-core</artifactId>
<version>0.8.20</version>
</dependency>
import org.msgpack.core.MessagePack;
import org.msgpack.core.MessagePacker;
import org.msgpack.core.MessageUnpacker;
import java.io.IOException;
public class MsgPackExample {
public static void main(String[] args) throws IOException {
MessagePack messagePack = new MessagePack();
byte[] encodedData = messagePack.write(new Person("John Doe", 25));
MessageUnpacker unpacker = messagePack.createUnpacker(encodedData);
Person decodedPerson = unpacker.read(Person.class);
}
static class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
}