On Tue, Oct 11, 2022 at 5:23 PM David Wallace <[email protected]> wrote: > > I have an ObjectMapper which happens NOT to be a JsonMapper, that I receive > from a component outside my control. > > I would like to do something equivalent to > objectMapper.disable(MapperFeature.USE_ANNOTATIONS); but this has been > deprecated since 2.13. The deprecation message tells me I should use > JsonMapper.builder().disable(MapperFeature.USE_ANNOTATIONS).build(), but > there is other configuration in my ObjectMapper that I need to preserve, and > creating a whole new JsonMapper just won't work for me. > > If my original object were a JsonMapper, I imagine I could use ((JsonMapper) > objectMapper).rebuild() to get a builder, then go from there. But it's not. > > Any idea how I can disable a MapperFeature on an ObjectMapper in a > non-deprecated way?
No, unfortunately in this case I'd suggest you using `disable()` (or `configure(MapperFeature)` but that seems deprecated as well). It will not be removed until Jackson 3.0. This is bit unfortunately as only 3.x has methods that would work in your case: basically there is method `rebuild()` that can be called on an existing ObjectMapper, to allow construction of a new mapper with different configuration. This is unfortunately something that cannot be implemented reliably in 2.x so the only mechanism is the deprecated method. -+ Tatu +- -- 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/CAL4a10iL3PL2kLkj62tQCnPTuDSzr2NbjnRmU%3Dc0tRXUmJ-Trg%40mail.gmail.com.
