File tree Expand file tree Collapse file tree 4 files changed +51
-1
lines changed
main/kotlin/tools/jackson/module/kotlin
test/kotlin/tools/jackson/module/kotlin/test/github Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ WrongWrong (@k163377)
3131# 2 .18.3 (not yet released)
3232
3333WrongWrong (@k163377 )
34+ * #904 : Fixed an error when serializing a `value class` that wraps a `Map`
3435* #900 : Fixed an issue where some tests were not running
3536
3637# 2 .18.0 (26-Sep-2024)
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ Co-maintainers:
3434#839 : Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName.
3535#835 : Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport.
3636
37+ 2.18 .3 (not yet released )
38+
39+ #904 : An error that occurred when serializing a `value class` that wraps a `Map`(#873) has been fixed.
40+
37412.18 .2 (27 - Nov - 2024 )
38422.18 .1 (28 - Oct - 2024 )
3943
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ object ValueClassUnboxSerializer : StdSerializer<Any>(Any::class.java) {
5656 return
5757 }
5858
59- ctxt.findValueSerializer(unboxed:: class .java).serialize(unboxed, gen, ctxt )
59+ ctxt.writeValue( gen, unboxed )
6060 }
6161}
6262
Original file line number Diff line number Diff line change 1+ package tools.jackson.module.kotlin.test.github
2+
3+ import tools.jackson.module.kotlin.defaultMapper
4+ import tools.jackson.module.kotlin.readValue
5+ import kotlin.test.Test
6+
7+ class GitHub873 {
8+ @Test
9+ fun `should serialize value class` () {
10+
11+ val person = Person (
12+ mapOf (
13+ " id" to " 123" ,
14+ " updated" to " 2023-11-22 12:11:23" ,
15+ " login" to " 2024-01-15" ,
16+ ),
17+ )
18+
19+ val serialized = defaultMapper.writeValueAsString(
20+ TimestampedPerson (
21+ 123L ,
22+ Person (person.properties),
23+ )
24+ )
25+
26+ val deserialized = defaultMapper.readValue<TimestampedPerson >(serialized)
27+
28+ assert (
29+ deserialized == TimestampedPerson (
30+ 123L ,
31+ Person (person.properties),
32+ )
33+ )
34+ }
35+
36+ @JvmInline
37+ value class Person (
38+ val properties : Map <String , Any >,
39+ )
40+
41+ data class TimestampedPerson (
42+ val timestamp : Long ,
43+ val person : Person ,
44+ )
45+ }
You can’t perform that action at this time.
0 commit comments