Skip to content
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

Should @Transient imply @JsonIgnore ? #344

Closed
StephenOTT opened this issue May 25, 2020 · 4 comments
Closed

Should @Transient imply @JsonIgnore ? #344

StephenOTT opened this issue May 25, 2020 · 4 comments

Comments

@StephenOTT
Copy link

working with scenarios where a class could have different forms of serialization (java vs smile, etc)

If the kotlin annotation @Transient is applied, should it trigger jackson to apply @JsonIgnore?

The javadoc for @Transient is:

Marks the JVM backing field of the annotated property as transient, meaning that it is not part of the default serialized form of the object.

Just a thought for discussion

@cowtowncoder
Copy link
Member

This is a good question. Even keyword transient is tricky, see MapperFeature.PROPAGATE_TRANSIENT_MARKER -- originally thought to only remove field as accessors, but later on requested to be more like @JsonIgnore to also remove the whole property (in case there is a getter).

@k163377
Copy link
Contributor

k163377 commented Feb 22, 2023

Fields with the Transient annotation will be transient on Java.
Thus, this seems like an issue to consider with databind.

// original
@Transient
var temp: Any? = null
// decompiled
@Nullable
private transient Object temp;

@cowtowncoder
Can you please forward it to databind or I will close it if there is a duplicate?

@cowtowncoder
Copy link
Member

I think that

 MapperFeature.PROPAGATE_TRANSIENT_MARKER

added via FasterXML/jackson-databind#296 in Jackson 2.6 might actually already do what is being asked.

If not, I think that the original submitter (@StephenOTT ) could choose to re-file at jackson-databind (referencing this issue), if further functionality wrt transient is desired.
I am not 100% sure what else might be needed beyond MapperFeature mentioned above.

For now, I think this can be simply closed.

@k163377
Copy link
Contributor

k163377 commented Feb 22, 2023

Thanks.

@StephenOTT
If you see a need for a new feature that is not covered by PROPAGATE_TRANSIENT_MARKER, please submit a new issue.

@k163377 k163377 closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants