-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
jackson-dataformat-ion
type serialization behavior
#234
Comments
Ok. Just to make sure I understand this correctly, the concept of native type ids is somewhat orthogonal to Streaming API, on the other hand, exposes existence of native type ids. But due to existing design, it can only indicate it globally (use native for all or none), not for specific types. With that, the current choice really is that user needs to indicate usage on per-call (read, write) basis: default setting exists for Generator (subtype of I am not sure if that helps in figuring out what to do with the change discussed here but thought it might help at least understand constraints. |
One quick question/note here: I am hoping to get 2.12.1 released in about 1 week (on Dec 29 or 30), and I think that this issue itself is not a blocked since the default behavior would be the same as that of 2.12.0. Anyway: I guess what I am asking is just that if there is something urgent wrt 2.12.1 itself (regarding #232 that added setting to allow avoiding writing of native type ids), please add a note here (or file separate issue for specific change; I think this is bigger question altogether). |
With #232 we have a path forward. This question isn't urgent- I don't even know for sure that it has a satisfying answer. I don't know from Jackson's perspective what's feasible or advisable here so I'm floating this issue to raise a discussion.
Agreed 100%, I make the same argument myself.
True :) If upgrading from the unreleased ("2.8") type serialization behavior to I don't understand how all the pieces fit together here yet- it doesn't seem to me that |
Sounds good. As to Native Type Id vs That is the situation at this point, anyway. I am open to improvement suggestions, as always. As to path forward it sounds like this issue does not block 2.12.1, and that #232 should be included even if it is likely incomplete solution wrt problem of using (or not) of native type ids. |
jackson-dataformat-ion polymorphic behaviors
SSCCE to demonstrate behaviors.
This sample code depends on
jackson-dataformat-ion
,jackson-annotations
,jackson-databind
, andjackson-core
.Available jackson-dataformat-ion behaviors:
v2.8
@JsonTypeInfo
annotations, no type information without explicit guidance.We need to modify the example to work with 2.8:
Afterwards it should yield:
Output
v2.9 - Present (2.12 release)
As.PROPERTY
from@JsonTypeInfo
annotation.@JsonTypeInfo
still needed to cause typed serialization.Assuming 2.10+ for consistent
IonValue
import statement.Output
After PR #232
Output
After PR #232, with native types disabled at Mapper construction
Output
Open Question: What is the ideal behavior?
After PR #232 both achievable
IonMapper
configurations won't serialize type data without e.g. a POJO annotation, but write behavior can seem a little surprising. A user who has attempted to configure property-based serialization of type information will be surprised to see it showing up as an annotation instead.An argument can be made that the most locally or specifically expressed user preference should control behavior, in which case a
@JsonTypeInfo
annotation should override format-native behavior. I.e. the serialization ofSubclass
above should naturally be:This is complicated by the fact that
As.Property
is the default for@JsonTypeInfo
. Take this example:The user has not specified
include
oras
and it's not obvious that the user does not want format-native type serialization behavior.This behavior doesn't emerge from
jackson-dataformat-ion
directly, but from JsonGenerator injackson-core
, AsPropertyTypeSerializer injackson-databind
, etc.I'm looking for some commentary on intent here, and what options might be available. It's not clear to me how much flexibility there is here.
The text was updated successfully, but these errors were encountered: