OK. I'm naively just calling findRootValueDeserializer() when I need to deserialize an object, which appears to work.I don't know where I'd construct a BeanProperty from to call the findContextual method.
Not sure I understand the purpose of ContextualDeserializer in this context. It doesn't help me create deserializers that I might want to use does it? Is there a good guide somewhere on how to do this? Thanks. On Thursday, 14 July 2016 21:01:56 UTC+1, Tatu Saloranta wrote: > > Yes, for delegation you would retrieve a JsonDeserializer via > DeserializationContext. > > However, for performance reasons this is most often done by implementing > ContextualDeserializer, and handling lookups from method > `createContextual()` which is called once after construction. This method > can access annotations, fetch deserializers to delegate, and then construct > a new instance with settings (it should NOT modify instance itself, as it > may be shared among multiple properties). > > Method to call depends on situation; most likely it is one of: > > * findContextualValueDeserializer(): handles contextualization (as name > implies), requires `BeanProperty` (which is passed to `createContextual()` > * findRootValueDeserializer(): called when this is the initial root > deserializer; also wraps TypeDeserializer for polymorphic types > > -+ Tatu +- > > > On Thu, Jul 14, 2016 at 8:39 AM, <[email protected] <javascript:>> wrote: > >> So I'm writing a custom deserializer, extending StdDeserializer<T>. >> >> I want the JSON structure to be slightly different to "normal", hence >> needing my own serializer and deserializer. >> >> Within the serializer I just call writeObjectField when I want to >> serialize the properties of my object, but I can't work out what the >> reverse of that is. >> >> So within my deserializer I want to be able to deserialize a value of >> given Class. So what I *think* I want to do is acquire a JsonDeserializer >> for a given Class from the DeserializationContext I have access to, but I >> can't work out how to do that. >> >> I've looked through some of the code, but I can't find anything that >> points me in the right direction. >> >> Any help would be appreciated. >> Thanks. >> >> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
