Get the word out, this is great for MPP folks!
i implemented like this on my common side
@Serializable
data class RestResponseDTO(
@SerialName(“payload”)
val payload:T,
@Contextual
val dt: LocalDateTime = testDateTime
)
and decoded like this on the ktor-client side:
private fun decodeList(input:String) : RestResponseDTO<List<BookDTO>>{ val decoded = Json.decodeFromString(RestResponseDTO.serializer(ListSerializer(BookDTO.serializer())), input) console.log(""" dayOfMonth : ${decoded.dt.dayOfMonth} year : ${decoded.dt.year} hour : ${decoded.dt.hour} minute : ${decoded.dt.minute} """.trimIndent()) console.log(decoded.dt == testDateTime) return decoded } suspend fun fetchAll() { val url = buildRestUrl(BookDTO.restStub) console.log(url) val resp = jsonClient.get<String>(urlString = buildRestUrl(BookDTO.restStub)) val obj = decodeList(resp) console.log(obj) }
there is probably a much better way to do this, but i am super happy that it is working!!!