Allow overriding of transient
with explicit inclusion with @JsonProperty
and/or way to ignore transient
#1184
Milestone
transient
with explicit inclusion with @JsonProperty
and/or way to ignore transient
#1184
The Java language has the
transient
property which indicates that certain fields should not take part in its Java object serialization framework of whichSerializable
is the hallmark.Jackson appears to conflate Java's 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 thetransient
keyword 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 therefore impossible to includetransient
fields in a Jackson serialization process.This becomes 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 (well supported bySharedPreferences
). 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 theSharedPreferences
storage, hence my setting these fields as transient (to exclude them from the latter, Java object serialization). Unfortunately, this makes Jackson ignore them wholesale, even when annotated@JsonProperty
(which is counter-intuitive - at a glance, one would expect a Jackson-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.As such, this is a feature request to provide the ability to disable filtering out all
transient
fields from Jackson's serialization process.The text was updated successfully, but these errors were encountered: