Lam Pham
08/08/2024, 4:35 PM%use ktor-client
). I need to configure a DataConversion to convert String to kotlin LocalDateTime object.
However, the conversion doesn't seem to be triggered 🧵Lam Pham
08/08/2024, 4:35 PMhttp.config {
install(DataConversion) {
convert<LocalDateTime> {
decode { values ->
println("Decoding")
...
}
encode { dates ->
println("Encoding")
}
}
}
}.get($url) {
...
}.body<Response>()
I consistently get Illegal input: java.time.format.DateTimeParseException: Text '20240808T164502+0100' could not be parsed at index 0
None of the println
is executed.
Do I miss anything?Chrimaeon
08/08/2024, 4:46 PMContentNegotiation
instead of DataConversion
https://ktor.io/docs/client-serialization.html#serialization_dependencyAleksei Tirman [JB]
08/09/2024, 7:33 AMDataConversion
plugin for the client side has an empty implementation of the install
method, so it does nothing. You can use this plugin for the server, though.Lam Pham
08/09/2024, 7:50 AMktor-client
is the only lib available
@Chrimaeon I can't really see how to do make it with ContentNegociation
anyway, I had to work around by using an intermediate object (with all String
fields) and manually do the conversion