I think the best approach would probably be to use type Any?
for code
.
Then you should write a custom GSon serializer/deserilizer (JsonDeserializer<BaseResponseEntity>
) for the BaseResponseEntity
object.
In this Json deserializer, you would need to check the type of value
(e.g is it a string or a data structure) and decode it to the correct object type.
Alternative, to avoid the use of Any?
, you could leave the model exactly as you have it. You will still need to write a custom JsonDeserializer
, however if value
is a string then it would still create a LastPaymentCodeModel
, using the string value as one of it's properties.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…