FasterXML / FasterXML/jackson-module-kotlin

Remove `NullToEmpty` options or change backend

Aperta
#877 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Kotlin
Stelle
1.2k
Fork
187
Merge medio
9h 48m
PR unite (30g)
16

Descrizione

### Use case
The `NullToEmptyCollection`/`Map` option can be replaced by `configOverride` as follows

```kotlin
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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.