FasterXML / FasterXML/jackson-module-kotlin

Feature flag to serialize unitialized lateinit properties into null

Open
#882 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
1.2k
Forks
187
Avg merge
9h 48m
Merged PRs (30d)
16

Description

### Use case

We log entity classes before saving them to the database

```
data class MyEntity(
val text: String,
... other required properties
) {
lateinit var createAt: Instant // this field is initialized after the entity is saved to the Database
}

fun save(entity: MyEntity) {
log.info("About to save ${objectMapper.writeValueAsString(entity)}")
repository.save(entity)
}
```

### Describe the solution you'd like

A new feature flag

```
val module = KotlinModule.Builder()
.configure(KotlinFeature.UnintializedLateInitToNull, true) // to write them as nulls
.configure(KotlinFeature.UnintializedLateInitToIgnore, true) // or to avoid them
.build()
```

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.