I actually didn’t solved. Suddenly it began doing ...
# ktor
c
I actually didn’t solved. Suddenly it began doing this thing of chopping my request again. I got to where it is happening but still don’t get why So, in the Ktor.JVM, when this data goes in: “Reminder(actionType=boolean, from=slorg@gmail.com, hours=[200], startDate=2020-10-29T013116.993Z, title=Hkkljf, to=jorebs@gmail.com, frequency=1, frequencyType=no_repeatable)” And when it goes trough package
Copy code
io.ktor.client.features.json.serializer
internal fun writeContent(data: Any): String =
    json.encodeToString(buildSerializer(data, json.serializersModule), data)
This is in like 29 this comes out: {“from”:“slorg@gmail.com”,“hours”[200],“startDate”“2020-10-29T013116.993Z”,“title”“Hkkljf”,“to”jorebs@gmail.com”}
m
What is the expected output? And how does your data class look like?
c
Man, I think it’s the serializer. I don’t understand how this is the only request that this happens
Copy code
fun toJson(field: Reminder): String {
    //Notice we call a serializer method which is autogenerated from our class
    //once we have added the annotation to it

    return Json.encodeToString(Reminder.serializer(), field)

}
import kotlinx.serialization.json.Json
Copy code
@Serializable
data class Reminder(
    var actionType: String? = ActionType.BOOLEAN.type.toLowerCase(),
    var from: String? = null,
    val hours: List<Int>? = null,
    val startDate: String? = null,
    val title: String? = null,
    var to: String? = null,
    var frequency: Int? = 1,
    var frequencyType: String? = FrequencyType.NO_REPEATABLE.name.toLowerCase()
)
This is what is supposed to go in “Reminder(actionType=boolean, from=slorg@gmail.com, hours=[200], startDate=2020-10-29T013116.993Z, title=Hkkljf, to=jorebs@gmail.com, frequency=1, frequencyType=no_repeatable)”
this is what’s comming out {“from”:“slorg@gmail.com”,“hours”[200],“startDate”“2020-10-29T013116.993Z”,“title”“Hkkljf”,“to”jorebs@gmail.com”} (
m
Json
doesn’t encode default values by default.
frequency
is
1
by default so it’s not encoded. See https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#encoding-defaults
❤️ 1