How to get to use GsonSerializer for ktor?

Viewed 1229

In https://ktor.io/docs/json.html#gson, I can see we can have GsonSerialzer as the code

install(JsonFeature) {
    serializer = GsonSerializer() {
        setPrettyPrinting()
        disableHtmlEscaping()
    }
}

But I can't seem to get to include this class. Which library should I import (in my Gradle) to have access to them?

2 Answers
implementation "io.ktor:ktor-client-gson:$ktor_version"

From the docs

A quick note, GSON will only work for JVM targets as its a java serialization/deserialization library.

If you have native targets then you probably want to use kotlinx-serialization (ktor-client-serialization)

Related