-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support Optional in Jackson 2 message converters #24498
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
Comments
…th java.util.Optional spring-projects#24498
Hi. I can confirm this issue. It works for collections thanks to Jackson support. My PR fixes "Optional" only, for the Page it should be placed in a different repo I believe, spring-data-rest maybe? |
I can confirm this too. Took me a while to find the cause of my problem. |
I don't see a way for Spring Framework to support Spring Data's |
This is now fixed. Our apologies for taking this long to resolve this issue. |
@poutsma Thank you! Should I request support for |
Affects: 5.2.3.RELEASE
Given an endpoint that returns a polymorphic JSON type, eg.
Jackson will serialize it with the property
@type
, eg.However, when wrapping it with an
Optional
/Page, the JSON polymorphism no longer works. Eg.returns:
According to FasterXML/jackson-databind#1594 this is due to type erasure, however the JSON polymorphism still works when wrapping with built-in
Collection
s (eg.List
/Set
/Map
), eg.So it seems like Spring has special handling for built-in
Collection
s. Is it possible to apply them toOptional
/Page as well?Currently the workaround is to create custom
JsonSerializer
s forOptional
/Page, eg.The text was updated successfully, but these errors were encountered: