I am using Retrofit with GSON for an app for a client, and I am having some trouble with some of my client APIs and I need to workaround this problem.
Let's say i have an API which gives me telephones:
{
"telephones": [
{"phoneNumber": "1234567890"},
{"phoneNumber": "2123456789"}
]
}
But my client decided if there is only one telephone i am sending you:
{
"telephones":
{"phoneNumber": "1234567890"}
}
And when there is no telephone:
{
"telephones": "No telephone Available"
}
Is there any workaround i can make with Kotlin to solve this datatype problem? In iOS I could force them reimplementing the Coding method and force them to always have an array. Is it possible to do something similar in Kotlin?
This is a small example, since the original answer has between 600 and 1300 lines of JSON data.