New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No attempt to resolve type for AnySetter. #337
Comments
Awww, why SettableAnyProperty and its #deserialize are final? Thank OSS, I was able to undertake it, but I would ask to not mark anything final. :)
to #deserialize calling
in the constructor. That is enough for me, because I use as.property type inclusion. |
I don't know whether it is a good idea to use polymorphic types via any-setter. To me that sounds like asking for trouble. You can handle conversions, if you choose to do so, by using "untyped" approach, pass a Map of String-to-Object mappings. As to SettableAnyProperty... that is not meant to be sub-classed; it is not an extension point. This is why it is declared as final. |
Well, if I'll use 'untyped' approach, I'll just do same work as Jackson can - find all maps (I don't hardcode possible keys), passed to AnySetter, find inclusion property value, determine the class and copy other properties. Such operation can be injected into current process, I believe. Plus it may be useful to allow a better deserialization of some 'primitives' - notably Date`s. With regard to final. The main reason I hate it is due to imposed requirement to modify source if some 'patch' is needed. Of course, this changes behavior, and may result in additional complexities while upgrading. But I would rather tick
and so on and so force. :) This usually much more easier then maintenance of modified artifact. And without subclassing, there is a need to override a bunch of classes, because for some reason they all expect concrete class. ;) |
Understood -- closing of doors saves trouble from some, adds more to others. I think what will work here is to first see if polymorphic typing can be supported -- I suspect it should, and it is just an oversight on my part. I hope to be able to check this out between 2.3.0-rc1 (now) and rc2 or final; if so, fix would be in 2.3.0-final. Thank you for reporting this! |
Ok, thank you. Looking forward to the best databinder becoming better. |
Added unit test, I can verify the problem: serialization does add type information properly, but deserializer does not handle it. |
Was easy fix, will be in 2.3.0-rc2 (if we do that), or 2.3.0 final. |
Ok, thank you. |
com.fasterxml.jackson.databind.deser.SettableAnyProperty#deserialize does not honor DefaultTypeResolver (and any other) - compare it to com.fasterxml.jackson.databind.deser.SettableBeanProperty#deserialize.
Without type resolving I, personally, cannot create a 'Patch' pojo, that will hold some metadata as bean props and actual data being deserialized through AnySetter.
So, answering a question at the class javadoc for SettableAnyProperty:
Yes, it makes sense to refactor to share some code * with {@link SettableBeanProperty} :)
Until then, how can I override? Extend com.fasterxml.jackson.databind.deser.BeanDeserializerFactory, override its #constructAnySetter to create instances of modified SettableAnyProperty? And modify Mapper's constructor to set a different _deserializationContext?
The text was updated successfully, but these errors were encountered: