-
Notifications
You must be signed in to change notification settings - Fork 174
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
Problems deserializing object when default values for constructor parameters are used #29
Comments
This would be hard to fix in Jackson since we cannot control the actual constructor call and it cannot call using the Kotlin reflection The only way we can handle this is if Jackson has a way for a plugin to do the actual constructor invoke and gives a list of all known parameters that it has to pass in, @cowtowncoder is it possible to have an extension point to do the actual construction? I need to know the decided constructor or factory method, and the parameters to be passed in along with any names given for the parameter from the implicit naming part of the plugin. At that point I can identify which are missing and do the special call returning an instance. Or the whole "here are the JSON properties I have, do something with them" step could be delegated to a plugin that can do a best fit match against constructor and properties and then ask for each one by the expected type and then do construction (which could be constructor + setting mutable properties). |
@apatrida Would this PR from jackson-databind -- FasterXML/jackson-databind#1224 -- be of any help here? It does give some control over to |
@cowtowncoder maybe, it looks like it is covering this type of case. I can quickly build on it to do default, nullable, and mixed model construction in Kotlin to find out. Is that on a SNAPSHOT build somewhere? |
@apatrida I think Travis has snapshot deploy enabled, but just in case I'll do explicit snapshot deploy now. |
so these go to sonatype snapshots or where is the snapshot repo? (maybe it is in the pom.xml if I read it, along with the version pushed) |
@apatrida Should go to Sonatype I think, as per default config. I rely on local snapshot builds so I am bit ignorant on where automated builds (or just |
I'm trying this out now... |
Fixed, committing soon. |
It would be cool if we could get this ported to 2.7.5 |
Depends if the patch FasterXML/jackson-databind#1224 can be backported to 2.7.x that this module change depends upon, @cowtowncoder / @michaelhixson? |
I'm having problems deserializing object when when default values for constructor parameters are used. Jackson is attempting to set a parameter that is missing in json to null in Kotlin even though the parameter has a default value. Here's the example that fails:
Here's the stacktrace:
The text was updated successfully, but these errors were encountered: