Jackson custom JsonSerializer - conditionally call default serializer

后端 未结 1 748
野趣味
野趣味 2020-12-21 09:22

What I want is to use default BeanSerializer conditionally for my class\'s objects:

class MyCustomSerializer extends StdSerializer {

          


        
相关标签:
1条回答
  • 2020-12-21 09:44

    This requires bit more complicated setup: instead of directly overriding serializer to use, you need to let Jackson create one, then take over. This may be done by registering BeanSerializerModifier (via Module), method modifySerializer(...). You will be given default serializer that would be used, and you can construct custom one, passing that default one.

    0 讨论(0)
提交回复
热议问题