added consideration for cases where the value wrapped by value class is null
MODIFY
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinAnnotationIntrospector.kt
@@ -94,6 +94,9 @@ internal class KotlinAnnotationIntrospector(private val context: Module.SetupCon
else -> null
}
+ // Perform proper serialization even if the value wrapped by the value class is null.
+ override fun findNullSerializer(am: Annotated) = findSerializer(am)
+
/**
* Subclasses can be detected automatically for sealed classes, since all possible subclasses are known
* at compile-time to Kotlin. This makes [com.fasterxml.jackson.annotation.JsonSubTypes] redundant.

MODIFY
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt
src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt
@@ -82,7 +82,7 @@ internal class ValueClassBoxSerializer(
) : StdSerializer<Any>(outerClazz.java) {
private val boxMethod = _handledType.getMethod("box-impl", innerClazz)
- override fun serialize(value: Any, gen: JsonGenerator, provider: SerializerProvider) {
+ override fun serialize(value: Any?, gen: JsonGenerator, provider: SerializerProvider) {
// Values retrieved from getter are considered validated and constructor-impl is not executed.
val boxed = boxMethod.invoke(null, value)

added consideration for cases where the value wrapped by value class is null