真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

MessagePackJavaJacksonDataformat在Map中不使用Str

當(dāng)你希望在 Map 中不使用 String 為 Key,那么你需要使用?MessagePackKeySerializer?來為 key 進(jìn)行序列化。

創(chuàng)新互聯(lián)公司2013年成立,先為高港等服務(wù)建站,高港等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為高港企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

本測試方法,可以在?https://github.com/cwiki-us-demo/serialize-deserialize-demo-java/blob/master/src/test/java/com/insight/demo/serialize/MessagePackSerializer.java?中找到。

/**
?*?testMessagePackSerializationMapKey
?*/
@Test
@JsonSerialize(keyUsing?=?MessagePackKeySerializer.class)
public?void?testMessagePackSerializationMapKey()?{
????logger.debug("testMessagePackSerializationNotCloseInputStream");

????byte[]?bytes?=?new?byte[0];
????Integer?uuid_a?=?101;
????Integer?uuid_b?=?102;

????//?Instantiate?ObjectMapper?for?MessagePack
????ObjectMapper?objectMapper?=?new?ObjectMapper(new?MessagePackFactory());

????Map?map?=?new?HashMap<>();
????MessageData?messageData?=?new?MessageData();

????//?Element?A?in?MAP
????messageData.setUuid(UUID.randomUUID().toString());
????messageData.setName("CWIKI.US?-?A");
????map.put(uuid_a,?messageData);

????//?Element?B?in?MAP
????messageData?=?new?MessageData();
????messageData.setUuid(UUID.randomUUID().toString());
????messageData.setName("CWIKI.US?-?B");
????map.put(uuid_b,?messageData);


????try?{
????????//?Serialize?a?Java?object?to?byte?array
????????bytes?=?objectMapper.writeValueAsBytes(map);
????????logger.debug("Length?of?Bytes:?[{}]",?bytes.length);

????????//?Deserialize?the?byte?array?to?a?MAP
????????Map?deserialized?=?objectMapper.readValue(bytes,?new?TypeReference>()?{
????????});
????????logger.debug("Deserialized?MAP?Count:?[{}]",?deserialized.size());
????????logger.debug("MAP?index?0:?[{}]",?deserialized.get(uuid_a).getName());

????????assertEquals("CWIKI.US?-?A",?deserialized.get(uuid_a).getName());

????}?catch?(JsonProcessingException?ex)?{
????????logger.error("Serialize?Error",?ex);
????}?catch?(IOException?e)?{
????????e.printStackTrace();
????}
}

?

https://www.cwiki.us/display/Serialization/MessagePack+Jackson+Dataformat


標(biāo)題名稱:MessagePackJavaJacksonDataformat在Map中不使用Str
網(wǎng)站路徑:http://weahome.cn/article/jiojee.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部