msgpack-java
msgpack-java copied to clipboard
Am I missing something, or has the API gotten massively more complicated?
I was previously using 0.6.8 and it was lovely and simple: create a packer, "write" primitives to it, create an unpacker, "read" primitives from it.
Now I can't for the life of me work out what I am supposed to do, there is no "read" method, no generic write method. There are various pack and unpack methods, but why on earth do the method names have the type in them, what's wrong with overloading a single "pack" and "unpack" method based on the parameter type?
To be a bit more concrete, if I want to read (or write), say 10, values from an unpacker, previously I would have done this:
Class<?>[] types = .....; // the types that I know I want to read, int, byte, etc.
Object[] components = new Object[10];
for (int i = 0; i < 10; i++)
components[i] = unpacker.read(types[i]); // a single read method
// now I am happy, in a few lines I have an array of all the primitives I want to read
Now it looks like I need to have some sort of massive switch statement that gets checked for each Value i read (via unpackValue), or else call a different method to read each entry (unpackInt, etc.)
It may be there is some way to get this going with the Variable class, or in some other way, but as there isn't any documentation, I literally can't work out how to get this working.
I'm guessing I am missing something, somewhere...