If you look at the code below the ENERC_KCAL,FAT,FASAT,FAMS all of them has the same 3 parameters label, quantity and unit. I want to set the label and quantity value in my RecyclerAdapter to populate a recylerView.
"totalNutrients":{
"ENERC_KCAL":{
"label":"Energy",
"quantity":2493.0949190757847,
"unit":"kcal"
},
"FAT":{
"label":"Fat",
"quantity":2.275,
"unit":"g"
},
"FASAT":{
"label":"Saturated",
"quantity":0.0665,
"unit":"g"
},
"FAMS":{
"label":"Monounsaturated",
"quantity":0.224,
"unit":"g"
}
}
However, in my data class, is creating individual objects of type ENERC_KCAL,FAT,FASAT,FAMS(I'm using the Json to Kotlin Class Plugin) in the following format
data class ENERCKCAL(
@SerializedName("label")
val label: String?,
@SerializedName("quantity")
val quantity: Double?,
@SerializedName("unit")
val unit: String?
)
data class FAT(
@SerializedName("label")
val label: String?,
@SerializedName("quantity")
val quantity: Double?,
@SerializedName("unit")
val unit: String?
)
data class FASAT(
@SerializedName("label")
val label: String?,
@SerializedName("quantity")
val quantity: Double?,
@SerializedName("unit")
val unit: String?
)
Is there a way to generate a GenericClass to access the label and quantity value or how do i access the values in the present structure?