作者:n重庆商报程红Lft | 来源:互联网 | 2023-09-25 12:52
使用protostuff系列化自定义对象时正常解析,但是使用HashMap却得不到反序列化的对象。
1 2 3 4 5 6 7 8 9
| HashMap map = new HashMap<>();
map.put("Message","test");
Schema schema = RuntimeSchema.getSchema(HashMap.class);
LinkedBuffer buffer = LinkedBuffer.allocate(4096);
byte[] protostuff = ProtostuffIOUtil.toByteArray(map, schema, buffer);
HashMap resultMap = new HashMap<>();
Schema schema2 = RuntimeSchema.getSchema(HashMap.class);
ProtostuffIOUtil.mergeFrom(protostuff, resultMap, schema2);
System.out.println(resultMap.get("Message")); |