-
-
Notifications
You must be signed in to change notification settings - Fork 228
Support for an easier way to deserialize missing values into an empty list? #742
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
May be more answers in stackoverflow or in chatgpt. It really helps if users are willing to check for existing solutions online. |
Annotating the record elment I indeed did some research and also had already tried the solution above before, but unfortunately, in the following process of simplifying my original code and narrowing down the problem I missed that in my original code I additionally set
With this set, the solution above doesn't seem to work, unfortunately. I guess what I would like to have is "fail on missing creator properties which are required, but for all "optional" types like |
Quick question: is this with the latest (2.18.3)? If not, please try with it. |
Yes, I used 2.18.3. I just created a repository with example code. |
Please consider the following scenario:
public record Bar(ArrayList<String> bar) {}
As stated in the comment in above code, I'd like missing values to be deserialized into an empty list. So far I managed to make this possible with these two approaches:
Bar
record which takes care ofnull
and returns an empy list.StdDeserializer
forBar
.I'd like to avoid approach 1) because I'd like to keep the parsing related functionality to annotations and not have it inside the record class. On the other hand, approach 2) requires a bigger setup. I was therefore wondering, is it possible to deserialize missing values into an empty list in an easier way - for example, like deserializing a missing value into an empty
Optional
is supported by registering theJdk8Module
- and if not, could this maybe be a feature in the future?The text was updated successfully, but these errors were encountered: