Skip to content

Commit 452149e

Browse files
authored
Merge pull request #905 from k163377/merge-2.18
2.18
2 parents 32dbb29 + af77407 commit 452149e

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ WrongWrong (@k163377)
3131
# 2.18.3 (not yet released)
3232

3333
WrongWrong (@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)

release-notes/VERSION-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
3741
2.18.2 (27-Nov-2024)
3842
2.18.1 (28-Oct-2024)
3943

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object ValueClassUnboxSerializer : StdSerializer<Any>(Any::class.java) {
6262
return
6363
}
6464

65-
provider.findValueSerializer(unboxed::class.java).serialize(unboxed, gen, provider)
65+
provider.defaultSerializeValue(unboxed, gen)
6666
}
6767
}
6868

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.fasterxml.jackson.module.kotlin.test.github
2+
3+
import com.fasterxml.jackson.module.kotlin.defaultMapper
4+
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
5+
import com.fasterxml.jackson.module.kotlin.readValue
6+
import kotlin.test.Test
7+
8+
class GitHub873 {
9+
@Test
10+
fun `should serialize value class`() {
11+
12+
val person = Person(
13+
mapOf(
14+
"id" to "123",
15+
"updated" to "2023-11-22 12:11:23",
16+
"login" to "2024-01-15",
17+
),
18+
)
19+
20+
val serialized = defaultMapper.writeValueAsString(
21+
TimestampedPerson(
22+
123L,
23+
Person(person.properties),
24+
)
25+
)
26+
27+
val deserialized = defaultMapper.readValue<TimestampedPerson>(serialized)
28+
29+
assert(
30+
deserialized == TimestampedPerson(
31+
123L,
32+
Person(person.properties),
33+
)
34+
)
35+
}
36+
37+
@JvmInline
38+
value class Person(
39+
val properties: Map<String, Any>,
40+
)
41+
42+
data class TimestampedPerson(
43+
val timestamp: Long,
44+
val person: Person,
45+
)
46+
}

0 commit comments

Comments
 (0)