如何将哈希Map从字节[]转换回来?

vjrehmav  于 2021-06-26  发布在  Java
关注(0)|答案(2)|浏览(275)

我已经使用对象Map器将hashmap转换为byte[]。就像下面一样

private static final ObjectMapper objectMapper = new ObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .registerModule(new JavaTimeModule());

Map<String, String> entries = new HashMap<>();
            entries.put("triggerId","123");
            entries.put("webhookId","456");

byte[] message=objectMapper.writeValueAsBytes(entries)

现在我想把它转换回hashmap。我该怎么做?

uqxowvwt

uqxowvwt1#

必须使用jackson对象Map器读取值。就像下面一样

Map result = objectMapper.readValue(message, Map.class);
gorkyyrv

gorkyyrv2#

我认为这是不可能的

相关问题