On Sat, Mar 10, 2018 at 4:38 PM, Bojan Tomic <veg...@gmail.com> wrote: > I was going through some critical sections of my code to look for potential > problems for the eventual upgrade to Jackson 3. > One thing that popped out was the usage of JsonParser#getCodec which no > longer exists. > > Is there any sort of replacement for it, in the sense of getting a hold of > ObjectMapper from inside the custom deserializer? > I'm fully aware this is not a good thing to do in general, but my library > contains a custom deserializer that delegates the actual > deserialization work to the framework-provided facility that in some > advanced cases requires access to ObjectMapper.
Replacement is public abstract ObjectReadContext getObjectReadContext(); where `ObjectReadContext` exposes similar set of methods to `TreeCodec`. One thing to note is that context implementation returned is NOT `ObjectMapper` but rather `DeserializationContext` (that is, implementation is by context, not mapper). So if upcasting, need to take care to know real type. As background, the reason change was made is that `ObjectMapper` (or `ObjectReader`) is essentially stateless and callbacks from parser would have to create new context, losing things like per-call attributes. Result is much smoother interaction when delegating, but it is obviously also backwards-incompatible change for some code. Also note that if necessary `ObjectReadContext` can still be changed, if it is missing functionality that would be useful and "belongs there" (that is, would make sense to add). -+ 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 jackson-user+unsubscr...@googlegroups.com. To post to this group, send email to jackson-user@googlegroups.com. For more options, visit https://groups.google.com/d/optout.