java - protostuff不能序列化HashMap?
PHP中文网
PHP中文网 2017-04-18 09:49:36
0
0
782

使用protostuff系列化自定义对象时正常解析,但是使用HashMap却得不到反序列化的对象。

HashMap<String,String> map = new HashMap<>();
        map.put("Message","test");
        Schema<HashMap> schema = RuntimeSchema.getSchema(HashMap.class);
        LinkedBuffer buffer = LinkedBuffer.allocate(4096);
        byte[] protostuff = ProtostuffIOUtil.toByteArray(map, schema, buffer);
        HashMap<String,String> resultMap = new HashMap<>();
        Schema<HashMap> schema2 = RuntimeSchema.getSchema(HashMap.class);
        ProtostuffIOUtil.mergeFrom(protostuff, resultMap, schema2);
        System.out.println(resultMap.get("Message"));
PHP中文网
PHP中文网

认证高级PHP讲师

Antworte allen(0)
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!