In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
In this test code, we define a POJO class called MessageData, which you can find at the link below.
https://github.com/cwiki-us-demo/serialize-deserialize-demo-java/blob/master/src/main/java/com/insight/demo/serialize/model/msgpack/MessageData.java
Serialization and deserialization of POJO
You simply instantiate MessagePackFactory and pass parameters to the constructor of com.fasterxml.jackson.databind.ObjectMapper.
You can then format the data using Message Pack in the same way as jackson-databind.
This test method can be found at https://github.com/cwiki-us-demo/serialize-deserialize-demo-java/blob/master/src/test/java/com/insight/demo/serialize/MessagePackSerializer.java
/** * SerializationPOJO */@Testpublic void testMessagePackSerializationPOJO() { byte[] bytes = new byte[0]; String uuid = UUID.randomUUID().toString(); // Instantiate ObjectMapper for MessagePack ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory()); MessageData pojo = new MessageData(); pojo.setUuid(uuid); pojo.setName("CWIKI.US"); try { // Serialize a Java object to byte array bytes = objectMapper.writeValueAsBytes(pojo); logger.debug("Length of Bytes: [{}]", bytes.length); // Deserialize the byte array to a Java object MessageData deserialized = objectMapper.readValue(bytes, MessageData.class); logger.debug("Deserialized Name: [{}]", deserialized.name); assertEquals("CWIKI.US", deserialized.name); } catch (JsonProcessingException ex) { logger.error("Serialize Error", ex); } catch (IOException e) { e.printStackTrace(); } }
https://www.cwiki.us/display/Serialization/MessagePack+Jackson+Dataformat
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.