By default, Moshi ignores null values in serialization, but in some case I DO want to serialize my object with null value, I've tried to create @JsonQualifier for this case, but in final result, null value was ignored.
How to ignore null values in serialization (toJson) but keep some specific field null ?
Example
@Retention(AnnotationRetention.RUNTIME)
@JsonQualifier
annotation class KeepItNull
data class StackQuestion(val id : Int){
var question : String? = null
@KeepItNull
val answer : String? = null
}
Response should ignore 'question' and include 'answer' field - like this:
{
"id": 1,
"answer": null
}