admin管理员组

文章数量:1122832

I have a rather complicated Class structure that is needed to be serialized into CBOR. Now issue is that sometimes I need CBOR with tags while other times I need without tags.

I'd like to be able to define the serializers only once and then have some sort of a toggle flag to tell the serialize if it should include tags or not.

I have

 private static final ObjectMapper CBOR_MAPPER = new ObjectMapper(new CBORFactory());

And it is used like this

CBOR_MAPPER.writeValueAsBytes(object)

Is there a way to somehow add additional options for specific serialization calls?

本文标签: javaCustom serializer for Jackson with toggleable optionsStack Overflow