How do I add a Jackson mixin to a reader and not to the objectmapper?

前端 未结 2 820
时光说笑
时光说笑 2021-01-18 20:04

I have an object that I would like to serialize with an attribute in one part of my program, but without in a different part. I also have an ObjectMapper which is extensive

2条回答
  •  Happy的楠姐
    2021-01-18 20:24

    Actually, you can configure mixins for serialization or deserialization (or both of course):

    objectMapper.getSerializationConfig().addMixInAnnotations(Rectangle.class, MixIn.class);
    objectMapper.getDeserializationConfig().addMixInAnnotations(Rectangle.class, MixIn.class);
    

    http://wiki.fasterxml.com/JacksonMixInAnnotations

提交回复
热议问题