Skip to content

Add test for #873 #894

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fasterxml.jackson.module.kotlin.test.github

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 = jacksonObjectMapper().writeValueAsString(
TimestampedPerson(
123L,
Person(person.properties),
)
)

val deserialized = jacksonObjectMapper().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,
)
}