-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Unable to deserialize Object with unknown Timestamp
field
#251
Comments
Version? |
com.fasterxml.jackson.dataformat:jackson-dataformat-ion:2.12.2 from maven central. |
I don't know too much about this module, but I suspect that a work-around to just pass values as "raw" objects through For 2.13 I plan on having a mechanism for backends to use custom |
Has anyone found a workaround for this one? |
Any updates/workarounds found for this issue? |
jackson-dataformat-ion
unable to deserialize hash with unknown timestamp fieldjackson-dataformat-ion
unable to deserialize Object with unknown timestamp field
Any update on this? As it is still not working with 2.16.1 and the only workaround we have been able to find is to create a custom serializer. |
Investigated more, and the behavior is inconsistent and dependent on if and where other fields are in the input data. If you add "count" before the timestamp, it works as expected - but not without it or if you add it after the timestamp. This seems especially problematic. `` import com.fasterxml.jackson.annotation.JsonCreator; public class TestTimestamp {
} |
I probably did not write part of the code relevant here, but I do know why serialization is invoked: because of the need to buffer incoming content: values that cannot yet be used -- which initially is anything that does not get passed via Construct arguments, such as ignored |
Checked failing test based on original report: that should be sufficient to reproduce and hopefully fix the issue. |
jackson-dataformat-ion
unable to deserialize Object with unknown timestamp fieldTimestamp
field
Thanks for the quick fix! |
@seadbrane Thank you for your help! Turns out it was much simpler than I thought, fortunately. |
That's similar to the workaround we were going to use, although just seemed odd that the change would really go in the serializer.
|
It is preferable to use |
Also: the reason code tries casting to Ion-specific generator is to use native datatype, via method only available on that generation -- but we can retain value as-is, "embedded", for |
Repro code:
Results in:
This looks to be because by default ObjectMapper will copy unknown fields into a TokenBuffer before figuring out how to handle them; it tries to use
TimestampSerializer
and passes in the TokenBuffer as the JsonGenerator, but since TokenBuffer is not an instance ofIonGenerator
the cast at line 39 fails.I see two potential options:
JsonGenerator
and tries to write out a string or int value if it's not anIonGenerator
; OR._deserializeUsingPropertyBased
overrridden, implementing logic to handle unknown fields using an Ion-based TokenBuffer or other such mechanism instead of the Json TokenBuffer.The text was updated successfully, but these errors were encountered: