Skip to content

Commit 2bf0f56

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19'
2 parents c74abfd + 452149e commit 2bf0f56

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-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/tools/jackson/module/kotlin/KotlinSerializers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)