An API I consume returns (among other fields) a mandatory telephone1
and an optional telephone2
. However, the JSON I fetch always contains both fields and a missing entry is displayed as an empty string.
{
"telephone1": "+1 555 1234",
"telephone2": ""
}
When the response is mapped to a pojo, is it preferable translate the empty string to null? Such as:
data class(
val telephone1: String,
val telephone2: String?
}
To me, this better communicates the possible states. Should I, though? Are there drawbacks?
Aucun commentaire:
Enregistrer un commentaire