Just as extra information, it looks like the prope...
# multiplatform
c
Just as extra information, it looks like the proper way to handle it is to add default values which is what I’m doing but it would be cool to know a more practical way to do this. Tsk, excuse me if this question doesn’t belong here but I’m having inconsistency with Ktor in my KMM project. Specifically serialisation. Looks like a simple issue, I actually never ran into it in android, but I don’t seem to find a proper answer, or at least one that I can grasp. I would like to know how to solve this: kotlinx.serialization.MissingFieldException: Field ‘X’ is required, but without adding default values. My setup in KMM is this:
Copy code
private val json = Json {
    isLenient = true; ignoreUnknownKeys = true; coerceInputValues = true; useArrayPolymorphism =
    true
}

internal val client = HttpClient() {
    install(JsonFeature) {
        serializer = KotlinxSerializer(json)
    }
}
I’m used to working only on Android and my setup usually looked like this:
Copy code
fun getRetrofit(): Retrofit {
    return Retrofit.Builder()
        .client(getOkHttpClientClient())
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .build()
}
1
d
@Cicero- Although this is pretty old thread, have you found a better practical way of handling this - during gradual migration is is an overhead and time consuming thing?
c
Hey, it's all about your Json configuration, I honestly can't remember more of tis problem 😬 Wanna describe your problem in more detail here?