Hey all :wave: Does someone have experience with s...
# jackson-kotlin
m
Hey all 👋 Does someone have experience with serialising kotlinx datetime objects? I'm currently baffled by a situation where de-serialising works just fine, but when trying to serialise the object, it yields unexpected output.
Copy code
data class DataPoint {
   @JsonFormat(
        shape = JsonFormat.Shape.STRING,
        pattern = "yyyy-MM-dd HH:mm:ss",
        timezone = "UTC")
    val time: Instant,
}
val mapper = jacksonObjectMapper()
mapper.registerModule(JavaTimeModule())

val dataPoint = DataPoint(time = Instant.parse("2001-09-09T01:46:40Z"))

val encoded = mapper.writeValueAsString(dataPoint)
assertEquals(
            "{\"time\":\"2001-09-09T01:46:40Z\"}",
            encoded,
        )
Unfortunately the encoded value for
time
looks like this an object, even though the shape was set to `STRING`:
Copy code
{
  "time": {
    "epochSeconds": 1000000000,
    "value$kotlinx_datetime": "2001-09-09T01:46:40Z",
    "nanosecondsOfSecond": 0
  }
}
any ideas?
d