Rob Elliot
08/16/2024, 1:42 PMorg.http4k.core.Response.body
to kotlin maps and lists, what's the best way to do it? I don't want lenses or data classes or anything like that...Rob Elliot
08/16/2024, 1:50 PMimport org.http4k.format.Moshi.auto
val lens = Body.auto<Map<String, *>>().toLens()
val response: Response = TODO()
val json: Map<String, *> = lens(response)
dave
08/16/2024, 2:28 PMMoshi.asA<Map<String, Any>>(Response(Status.OK).bodyString())
Rob Elliot
08/16/2024, 2:29 PMdave
08/16/2024, 2:32 PMinline fun <reified T: Any> HttpMessage.data(): Map<String, Any> = Body.auto<Map<String, Any>>().toLens()(this)
dave
08/16/2024, 2:33 PMresponse.json<Map<String, Any>>()
There are a few ways! 😂