Almost but not quite. Use of `@JsonTypeInfo(include=As.WRAPPER_OBJECT)` would indeed allow use of JSON property name as type identitifier. This would work for property values, and Lists/Arrays, but not quite the way you'd want for Maps.
So if I understand use case correctly, there is nothing out of the box to do that, and custom Map (de)serializer would be needed. While ContextualDeserializer may be useful in registering custom deserializer, it does not help directly: createContextual() will called exactly once, when constructing deserializer, and not during deserialization process itself (contextual here simply meaning that it can access annotation information, given POJO property information; and not contextual with respect to deserialization process itself). -+ Tatu +- ps. Such functionality has actually been informally asked before, so you could file an RFE -- I can see the usefulness, even if I don't quite know how this should be implemented (or configured via annotations) On Sun, Feb 19, 2017 at 4:37 PM, David Corbin <dcor...@dcorbin.com> wrote: > Foo is an interface, with several varied concrete classes. I do not have > type information imbedded in the objects, but based on the key of the map, I > can tell you the concrete type. > > Do, I have something like this in json: > > { > "id" : "12", > "elements" : { > "alpha" : { > "host" : "google.com", > "port" : 1717 > }, > "manager" : { > "first_name": "Fred", > "last_name": "Smith", > "age": 19 > } > } > } > > So, I know that "alpha" should be class Alpha, and "manager" is of type > Person > > I thought I might be able to use ContextualDeserializer, but when I define > custom deserializer with ContextualDeserializer, createContextual() is > called the property is "elements", not "alpha" or "manager". Is there some > way in the deserializer I can identify to tell if I'm deserializing "alpha", > or "manager" ? > > > -- > 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. -- 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.