Hi, How do I pass an instance of `Gson` in the `Co...
# ktor
o
Hi, How do I pass an instance of
Gson
in the
ContentNegotiation
block? This doesn’t work:
Copy code
val gsonInstance: Gson = ...

           install(ContentNegotiation) {
                gson {
                    gsonInstance
                    setPrettyPrinting()
                    setLenient()
                }
            }
a
Copy code
val gsonInstance: Gson = GsonBuilder().apply {
    setPrettyPrinting()
    setLenient()
}.create()

embeddedServer(Netty, port = 4444) {
    install(ContentNegotiation) {
        val converter = GsonConverter(gsonInstance)
        register(ContentType.Application.Json, converter)
    }
}
💯 1
👍 1