I wrote a jackson module to enable a specific type of serialization. Now i want to enable global configuration of one of the new serializers. so i have to set a property on a serializer instance during creation.
Is there a way i can do that from within a jackson module?
Module interface is stateless, one-of-thing, so it does not have default wiring to affect things it adds.
But what you can do is to use a work-around; possibilities include:
ThreadLocal
; set before serialization, read from serializerObjectWriter.setAttribute()
) and reading (ObjectReader.setAttribute()
), accessible by serializer/deserializer through context object (SerializerProvider
/DeserializationContext
)So hopefully one of these works for your use case.