-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Deserialize missing value of EXTERNAL_PROPERTY
type using custom NullValueProvider
#3533
Comments
I gave this a go here, with this my use case works fine: fxshlein@a965ec7 I have no idea what other magic this perhaps breaks or where a test for this would belong however, so any ideas there would be greatly appreciated. |
Hmmh. I was about to suggest that I don't think I have time in near future to look deeper into this, but I'd be happy to help with PR if someone has time to figure out if handling can be improved. |
Given that the |
@fxshlein Ok that sounds good. Do you think you could do a PR for fix, and we get to see that unit test suite passes etc? |
Sorry took a while to get back - created the PR! |
… to underlying AsArrayTypeDeserializer (#3558)
EXTERNAL_PROPERTY
type using custom NullValueProvider
EXTERNAL_PROPERTY
type using custom NullValueProvider
Merged, will be in 2.14.0. |
Is your feature request related to a problem? Please describe.
I am currently trying to deserialize a structure with a generic field that has an external type property, where the type property is always present, but the actual property may be absent, in which case it should just use a custom
NullValueProvider
.The json can either look like this:
Or like this, in which case
value
should use theNullValueProvider
:The outer type looks like this:
And the inner types all implement this interface:
With an implementation of the inner type looking like this:
Each implementation of
Inner
also has a deserializer which implements thegetNullValue
method:I have also disabled
FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
.The first snippet deserializes without problems, and when I remove
required = true
from the value property, the second snippet deserializes withWrapper#value
beingnull
. Withrequired = true
however, acom.fasterxml.jackson.databind.exc.MismatchedInputException
is thrown.The exception originates from this part of the jackson databind codebase.
Describe the solution you'd like
In the linked snippet of jackson code, it would in my opinion be appropriate to use the custom
NullValueProvider
s ifFAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
is disabled.Usage example
The feature would work like shown above, however depending on how reasonable this approach generally is, the option
FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
could be disabled by default.Additional context
The underlying
WRAPPER_ARRAY
property used in the background byEXTERNAL_PROPERTY
was already changed to support this behaviour: #2467The text was updated successfully, but these errors were encountered: