My response returning colors as strings. So I can get background color like "home_background" etc. I then take string and convert it to color from resource with same name. I do not want to do this in View ( Composables ) I want to create gson deserializer to parse it. Here is my data class:
data class QuestionTile(
override val id: String,
override val type: String,
override val author: Author,
override val createdDate: String,
override var text: PostText?,
override val topComment: Comment?,
override val seeAllCommentsAction: DeeplinkAction?,
override val allComments: List<Comment?>?,
override val tags: List<Tag>?,
val reactions: PostReactions,
val description: String?,
val backgroundColor: Color?,
val textColor: Color?
)
data class Color(
val color: Int
)
And i am not sure how to make deserializer that will take jsonObject["backgroundColor"].asString or jsonObject["textColor"].asString. Maybe tomorrow i will have new field like weirdColor and i just want to make my deserializer somehow dynamic.