Hey! the ktor gson module only responds with appli...
# ktor
n
Hey! the ktor gson module only responds with application/json when the client asks for it. Is there a way to change this behavior?
d
Maybe then you can just return a json using an extension method like this:
Copy code
suspend fun ApplicationCall.respondJson(obj: Any?) {
    this.respondText(jacksonObjectMapper().writeValueAsString(obj), ContentType.Application.Json)
}
The idea is that the content-negotiation decides how to convert the object based on the client preferences (json or xml or whatever), so returning always would break that point. So my suggestion is to not use the feature, and create an extension method like the one I have proposed to simply emit JSONs
n
I'll do that - thanks!
👌 1