Kotlin + Retrofit + Moshi
In case you want to conditionally ignore fields, you can set it to zero.
data class User(var id: String, var name: string?)
val user = User()
user.id = "some id"
user.name = null
Generated Json will be
user{
"id": "some id"
}
source
share