You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Value class throw exception when Jackson default typing is activated
To Reproduce
data class MyDataClass(val myValue: Any)
@JvmInline
value class MyValueClass(val myValue: String)
val objectMapper = ObjectMapper().apply {
activateDefaultTyping(polymorphicTypeValidator, DefaultTyping.NON_FINAL, As.PROPERTY)
registerKotlinModule()
}
objectMapper.writeValueAsString(MyDataClass(MyValueClass("my value")))
Output :
Type id handling not implemented for type java.lang.Object (by serializer of type com.fasterxml.jackson.module.kotlin.ValueClassUnboxSerializer) (through reference chain: fr.maif.epa.backmobile.commons.infrastructure.cache.CacheServiceTest$MyDataClass["myValue"])
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Type id handling not implemented for type java.lang.Object (by serializer of type com.fasterxml.jackson.module.kotlin.ValueClassUnboxSerializer) (through reference chain: fr.maif.epa.backmobile.commons.infrastructure.cache.CacheServiceTest$MyDataClass["myValue"])
at app//com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
Expected behavior
Jackson module Kotlin should be able de serialize/deserialize this kind of value with Jackson default typing
This is not a problem caused by jackson-module-kotlin or value class.
It is possible to reproduce this problem even with code that can be written only in Java, for example
The cause of this problem is that StdSerializer does not take ObjectIdWriter into account (it only works correctly when serialized with BeanSerializer).
If you need a new feature, please submit an issue to jackson-databind.
This issue will be closed.
As a side note, deserialization of value class is not yet supported (#650).
Describe the bug
Value class throw exception when Jackson default typing is activated
To Reproduce
Output :
Expected behavior
Jackson module Kotlin should be able de serialize/deserialize this kind of value with Jackson default typing
Versions
Kotlin: 1.7.0
Jackson-module-kotlin: 2.13.3
Jackson-databind: 2.13.3
Additional context
Model used to reproduce is a simplified one, just to put in light the current behavior (remove sealed class, complex type in value class etc...).
The text was updated successfully, but these errors were encountered: