[英]JAVA serialize map as list BUT only for a specific ObjectMapper
有沒有一種方法可以將我的地圖序列化為json列表,但僅針對特定的ObjectMapper?
我用@JsonSerialize添加了我的自定義序列化類,它可以正常工作,但我只想將其用於特定的ObjectMapper。
這可能嗎 ?
是的,這應該可行。 您需要為第二個ObjectMapper
注冊一個模塊。
final SimpleModule module = new SimpleModule();
module.addSerializer(Map.class, new YourCustomSerializer());
module.addDeserializer(Map.class, new YourCustomDeserializer());
objectMapper.registerModule(module);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.