Hi Nausadh,
MapValue type is one of abstract representation in MessagePack for
Java. MapValue is different from your "map" object. The key and value
types are Value type. You can serialize Map<Integer, String> objects
as following:
import static org.msgpack.template.Templates.TInteger;
import static org.msgpack.template.Templates.TString;
import static org.msgpack.template.Templates.tMap;
import java.util.HashMap;
import java.util.Map;
import org.msgpack.MessagePack;
import org.msgpack.template.Template;
public class Main {
public static void main(String[] args) throws Exception {
// We unrecommend that you serialize/deserialize Object types
with MessagePack.
Map<Integer,String> src = new HashMap<Integer, String>();
src.put(1,"ONE");
src.put(2,"TWO");
MessagePack msgpack = new MessagePack();
// create template object, which is serializer/deserializer
for Map<Integer, String> object.
Template<Map<Integer, String>> tmpl = tMap(TInteger, TString);
byte[] bytes = msgpack.write(src, tmpl);
Map<Integer, String> dst = msgpack.read(bytes, tmpl);
System.out.println(dst);
System.out.println(dst.get(1));
}
}
----
Thanks,
Muga
> --
> You received this message because you are subscribed to the Google Groups
> "MessagePack Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
msgpack-dev...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>