I need to generate a data class at run time based on my REST API response with the given class name , and need to access it .Here is the sample json response and expected sample data class .
1) Sample JSON RESPONSE
"total": 123,
"currentCount": 10,
"items": [
{
"id": 5265194,
"name": "Sample",
"type": "Simple",
}
]
}
2)Expected Data Class
data class Sample(
@JsonProperty("currentCount")
var currentCount: Int = 0,
@JsonProperty("items")
var items: List<Item> = listOf(),
@JsonProperty("total")
var total: Int = 0
) {
data class Item(
@JsonProperty("id")
var id: Int = 0,
@JsonProperty("name")
var name: String = "",
@JsonProperty("type")
var type: String = ""
)
}