Hildebrandt Tobias
09/10/2025, 7:56 AM2025-09-02T10:59:38+02:00 and at one point (envelope) I deserialize it as Instant with no problem.
At another point (payload) I want to do the same but it doesn't work. I looked at the imports but both import kotlinx.datetime.Instant .
But one does so from org.jetbrains.kotlinx:kotlinx-datetime and the other from org.jetbrains.kotlinx:kotlinx-datetime-jvm , with the latter not working.
The only dependency I have in both my common and jvmBackend modules is org.jetbrains.kotlinx:kotlinx-datetime so I guess it selects which one to use by itself.
What would be the best course of action to remedy this Problem?
Edit: Seems like I have to use Instant.parse() , before I had the json serializer do it, since most payloads are json and a select few are plain strings, but before I had no problems
just using the json parser for that and it allowed me to have a more generic approach for all messages.Klitos Kyriacou
09/10/2025, 9:11 AMHildebrandt Tobias
09/10/2025, 9:16 AMHildebrandt Tobias
09/10/2025, 9:20 AMdata class MyEnvelope(
val timestamp: Instant
}
json.deserialize<MyEnvelope>(message)
with message being
{
timestamp: "2025-09-02T10:59:38+02:00"
}
Which worked.
But
json.deserialize<Instant>(message)
with message
2025-09-02T10:59:38+02:00
doesn't work.Klitos Kyriacou
09/10/2025, 4:12 PMkotlinx.datetime.Instant from an ISO string, because Instant is a inline value class, and so the function sees it as just a Long.