In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
When you want to Key without using String in Map, you need to use MessagePackKeySerializer to serialize the key.
This test method can be found in 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 An 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
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.