-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Supports deserialization of value class
(inline class
).
#650
Comments
Support for As |
cross-posting |
Deserializing a map where the key is a value class does not work in 2.17 unfortunately: import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@JvmInline
value class Id(val value: Int)
data class Foo(val valuesById: Map<Id, String>)
val objectMapper = jacksonObjectMapper()
val serialized = objectMapper.writeValueAsString(Foo(mapOf(Id(1) to "one", Id(2) to "two")))
val deserialized = objectMapper.readValue(serialized, Foo::class.java) Throws:
|
@geirsagberg I guess this would be better reported in a dedicated issue |
Created an issue: #777 |
jackson-module-kotlin
currently does not support deserialization ofvalue class
.This issue summarizes information about deserialization support for
value class
.About why
jackson-module-kotlin
has difficulty supportingvalue class
.The main reason it is difficult to support
value class
injackson-module-kotlin
is that the bytecodes for thevalue class
and its associated arguments and return values are different than usual.Jackson
is aJava Reflection
based library and cannot fully parse such content.As far as I have tried in the experimental project described below, I have already found that full support is impractical unless an option is provided by
Kotlin
to ensure compatibility.Implementation status of
value class
support.value class
support is being preliminarily implemented in the following experimental project.At this time, I have confirmed that it works in many major cases, even for deserialization.
https://github.com/ProjectMapK/jackson-module-kogera
The implementation of this project will be incorporated into
jackson-module-kotlin
in the future.The following issue also has information.
#199 (comment)
The text was updated successfully, but these errors were encountered: