Skip to content

Remove NullToEmpty options or change backend #877

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

Open
k163377 opened this issue Jan 5, 2025 · 0 comments
Open

Remove NullToEmpty options or change backend #877

k163377 opened this issue Jan 5, 2025 · 0 comments

Comments

@k163377
Copy link
Contributor

k163377 commented Jan 5, 2025

Use case

The NullToEmptyCollection/Map option can be replaced by configOverride as follows

jacksonObjectMapper().apply {
    configOverride(List::class.java).setterInfo = JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY)
    configOverride(Map::class.java).setterInfo = JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY)
}

Also, the current NullToEmpty option only applies to deserialization using creators and not to setters, a problem that will be resolved.

Describe the solution you'd like

Removing these options provides the following benefits

  1. Reduce the number of codes to be maintained
  2. Minor performance improvement for when the value is nullish

Describe alternatives you've considered

The disadvantage of this method is that it requires an explicit specification for each type.
For example, a specification for List will not apply to an ArrayList.
Similarly, a specification made for a Collection will not apply to a List or Set.

Therefore, the policy may be to switch only the backend of the process and leave it as a function.

Additional context

@k163377 k163377 changed the title Remove NullToEmpty options in the future. Remove NullToEmpty options or change backend Jan 5, 2025
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

1 participant