You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Java language has the transient property to indicate that certain fields should not take part in object serialization. This keyword is part of its own internal object serialization framework of which Serializable is the marker that you're subscribing to it.
Jackson appears to conflate Java object serialization configuration with its own by forcing all transient fields to be excluded from any Jackson serialization. While it is a good idea for transient to provide a hint to Jackson that the field is uninteresting for its own serialization, the problem is really that this behaviour cannot be turned off. It is utterly impossible to include transient fields in a Jackson serialization process.
This becomes painfully obvious when the application uses an object for two distinct types of serialization. Case in point, I want to serialize an object in Android for storage within its SharedPreferences by serializing it using Java's object serialization which SharedPreferences supports well. I also want to serialize this object into JSON for submission to a remote server via HTTP. When I serialize the object into JSON, I need to include a few data points that should not be included in the SharedPreferences storage, hence my setting these fields as transient. Now, Jackson ignores them wholesale, even when annotated @JsonProperty, which is counter-intuitive (at a glance, once would expect an annotated property to override a non-specific language keyword). There is also no way to change the configuration of the Jackson serialization mechanism to stop ignoring the transient keyword.
The text was updated successfully, but these errors were encountered:
@lhunath for larger discussion please use mailing lists. General discussion on usage of transient marker would fall under this category; especially since this is the first time in past 8 years when this has been reported as a significant issue.
I assume what you want is something like "allow serialization of transient fields" or such. If so, issue should go in jackson-databind as jackson-core contains streaming parser and generator which have no role in databinding aspect, including handling of transient fields.
So if you could re-file this over there (I would move it but AFAIK github has no "transfer issue" functionality, alas), that would make sense.
Also: instead of arguing with deeper semantics on your personal views, it makes sense to explain actual expected behavior. I do not take claims of generally accepted consensus at face value -- especially in cases where there exists plenty of prior art to the contrary (many if not most Java serialization frameworks outside of JDK serialization take transient keyword to mean exclusion).
I have nothing against proposed improvements for allowing alternate handling, I just dislike strong statements without much backing facts.
The Java language has the
transient
property to indicate that certain fields should not take part in object serialization. This keyword is part of its own internal object serialization framework of whichSerializable
is the marker that you're subscribing to it.Jackson appears to conflate Java object serialization configuration with its own by forcing all
transient
fields to be excluded from any Jackson serialization. While it is a good idea fortransient
to provide a hint to Jackson that the field is uninteresting for its own serialization, the problem is really that this behaviour cannot be turned off. It is utterly impossible to includetransient
fields in a Jackson serialization process.This becomes painfully obvious when the application uses an object for two distinct types of serialization. Case in point, I want to serialize an object in Android for storage within its SharedPreferences by serializing it using Java's object serialization which SharedPreferences supports well. I also want to serialize this object into JSON for submission to a remote server via HTTP. When I serialize the object into JSON, I need to include a few data points that should not be included in the SharedPreferences storage, hence my setting these fields as
transient
. Now, Jackson ignores them wholesale, even when annotated@JsonProperty
, which is counter-intuitive (at a glance, once would expect an annotated property to override a non-specific language keyword). There is also no way to change the configuration of the Jackson serialization mechanism to stop ignoring thetransient
keyword.The text was updated successfully, but these errors were encountered: