On Thu, Oct 14, 2021 at 7:40 PM Sasa Vilic <[email protected]> wrote:
> Hi, > > is there a way to pass configuration to customer serializer, for given > ObjectMapper instance? > > Background: > > I have created custom UUID serializer/deserializer with idea that I want > support both legacy/hex format and advanced efficient format in form of > array of 2 long values (MSB and LSB). > > My deserializer can read both format, based whenever first token is > ARRAY_START or not. > > But I have issue with configuring serializer. It only writes in hex format > and I would like to configure it differently for particular ObjectMapper > instance (when I know it is safe to used advanced format). > > But I can't figure out how to pass configuration to serializer? Another > option would be to override some configuration about types (i.e. UUID > class) but I can't find way either to do it. > > Do you have any suggestion? > Slow reply, but... I am not sure what you are asking? When registering your custom serializer via ObjectMapper, you will pass the specifically configured instance. Or are you using annotations (`@JsonSerialize`)? If the question is about how to change settings based on things, you may want to look into implementing `ContextualSerializer`: this method gets called with information on what property serializer is going to be used on -- and this gives access to annotations for the property (or detecting case of "root value", not referenced via property). -+ Tatu +- > > Kind Regards > Sasa Vilic > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jackson-user/8686c426-7941-475d-aaf0-4be61f8e4798n%40googlegroups.com > <https://groups.google.com/d/msgid/jackson-user/8686c426-7941-475d-aaf0-4be61f8e4798n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAGrxA24%3DGSfVHCxbQfds8av%3DuT1r-YBsUJmOETFiCFiw4XESnA%40mail.gmail.com.
