https://kotlinlang.org logo
#ktor
Title
# ktor
s

Susmitha Gudapati

07/26/2022, 9:14 PM
Hi, I’m using ktor’s
ParametersBuilder
to build params from JsonObject and I see that double quotes are added to my query params’ values. Can someone help me in correcting or handling this ?
Attaching the code here -
Copy code
val jsonObject = this.httpApiClient.json.encodeToJsonElement(
            kClass.serializer(),
            params
        ).jsonObject
        val parametersBuilder = ParametersBuilder(10, UrlEncodingOption.NO_ENCODING)
        jsonObject.entries.forEach { it ->
            this.appendParameter(
                parametersBuilder,
                null,
                it.key,
                it.value
            )
        }
and appendParamater basically does this. -
Copy code
when (value) {
            is JsonNull -> Unit
            is JsonPrimitive -> builder[finalKey] = value.jsonPrimitive.content
            is JsonArray -> builder.appendAll(
                finalKey,
                value.jsonArray.map { it.jsonPrimitive.content })
a

Aleksei Tirman [JB]

07/27/2022, 6:58 AM
Could you please tell me for what types of JSON values your parameters contain double quoted values? How do you check that they are quoted? What version of Ktor do you use?
127 Views