Nikky
02/11/2019, 7:26 AMencodeDefaults = false
in Json
constructor callgalex
02/11/2019, 4:57 PMHttpClient(Js) {
install(JsonFeature) {
serializer = KotlinxSerializer(Json(encodeDefaults = false))
}
Seems ok right?galex
02/11/2019, 5:11 PM@Serializable
data class Profile(
val id: Int,
val firstName: String? = null,
val lastName: String? = null) {
constructor(user: User): this(user.id, user.firstName, user.lastName)
}
galex
02/11/2019, 5:17 PMNikky
02/11/2019, 9:43 PM@Optional
to each value with default values, i wonder if it is because you add a constructorNikky
02/11/2019, 9:45 PM@Serializable
data class Profile(
val id: Int,
@Optional val firstName: String? = null,
@Optional val lastName: String? = null) {
}
this should certainly work.. maybe try turning your contructor into a companion object method like operator fun invoke(user: User)