Skip to content

2.18 #905

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

Merged
merged 5 commits into from
Feb 2, 2025
Merged

2.18 #905

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ WrongWrong (@k163377)
# 2.18.3 (not yet released)

WrongWrong (@k163377)
* #904: Fixed an error when serializing a `value class` that wraps a `Map`
* #900: Fixed an issue where some tests were not running

# 2.18.0 (26-Sep-2024)
Expand Down
4 changes: 4 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Co-maintainers:
#839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName.
#835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport.

2.18.3 (not yet released)

#904: An error that occurred when serializing a `value class` that wraps a `Map`(#873) has been fixed.

2.18.2 (27-Nov-2024)
2.18.1 (28-Oct-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object ValueClassUnboxSerializer : StdSerializer<Any>(Any::class.java) {
return
}

provider.findValueSerializer(unboxed::class.java).serialize(unboxed, gen, provider)
provider.defaultSerializeValue(unboxed, gen)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.fasterxml.jackson.module.kotlin.test.github

import com.fasterxml.jackson.module.kotlin.defaultMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import kotlin.test.Test

class GitHub873 {
@Test
fun `should serialize value class`() {

val person = Person(
mapOf(
"id" to "123",
"updated" to "2023-11-22 12:11:23",
"login" to "2024-01-15",
),
)

val serialized = defaultMapper.writeValueAsString(
TimestampedPerson(
123L,
Person(person.properties),
)
)

val deserialized = defaultMapper.readValue<TimestampedPerson>(serialized)

assert(
deserialized == TimestampedPerson(
123L,
Person(person.properties),
)
)
}

@JvmInline
value class Person(
val properties: Map<String, Any>,
)

data class TimestampedPerson(
val timestamp: Long,
val person: Person,
)
}