I have a json response which is a list of list of objects, I am trying to serialize it. How do I Serialize it with kotlin serializer?
{
"body": [
[
"Fresho Apple - Royal Gala, Regular, 4 pcs",
"Red",
"146",
82878,
"Fruit",
"40033823",
4,
600,
36.5,
"Turkey",
"Best before 3 days from delivery date",
"A combination of slightly tart-tasting skin and honey floral-tasting flesh, the Royal Gala apples, as the name suggests looks regal with beautiful golden-coloured streaks. Royal Gala apples are a good source of fibre and vitamin C, and they are a healthy snack or addition to a meal.",
620,
"https://www.bigbasket.com/cookbook/recipes/1611/apple-crumble-pie/",
"2023-06-06T18:30:00Z",
false,
false,
true
]
]
}
I have created the data class,
@Serializable
data class Response(
val body: List<List<Any>>
)
@Serializable
data class Product(
val title: String,
val color: String,
val price: String,
val id: Int,
val type: String,
val ean: String,
val count: Int,
val weight: Int,
val pricePerPiece: Float,
val countryOfOrigin: String,
val expiry: String,
val Description: String,
val nettWeight: Int,
val link: String,
val date: String,
val isUnavailable: Boolean,
val isCooked: Boolean,
val isFruit: Boolean
)
I am stuck with this, how to convert the data type to a list so that we can map it to the Product?
>` which i need to map to `List`
– Elo1422 Jul 01 '23 at 09:48>' from a server.
– Samir Ramic Jul 02 '23 at 12:46