使用protostuff系列化自定义对象时正常解析,但是使用HashMap却得不到反序列化的对象。
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"));
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师