https://kotlinlang.org logo
Title
s

Shawn Karber_

07/01/2020, 4:34 PM
I am trying to get the example code to work listed here: Json - Clients - Ktor , notable:
val client = HttpClient(HttpClientEngine) {
    install(JsonFeature) {
        serializer = GsonSerializer()
    }
}
but theres an issue with
HttpClient(HttpClientEngine)
The error says
HttpClientEngine
does not have a companion object, thus must be initialized here, what am I doing wrong?
i

Ivan

07/01/2020, 6:03 PM
I think you should use an implementation of HttpClientEngine. U can find all available client at this link https://ktor.io/clients/http-client/engines.html
☝️ 1
s

Shawn Karber_

07/01/2020, 7:03 PM
that was right, i didnt realize that HttpClientEngine was just a placeholder for the engine you wanted to use
👍 1
On another note, I am getting back a result now, of a valid json object, but when I convert it to a json string with Gson its adding whitespace everywhere (\r\n) everywhere, any ideas?
the file itself does have whitespace in it
i

Ivan

07/02/2020, 6:42 AM
I think the problem is in the configuration of your gson instance. did you add prettyprinting() to your gsonbuilder?
s

Shawn Karber_

07/02/2020, 11:49 AM
no, i hadnt, thanks a lot!