I have the following JSON array:
[
[
{
"body": "Text",
"bodyType": "Text",
"nameType": "Text",
"makeDisplay": "Acura"
}
],
[
{
"body": "text",
"bodyType": "text",
"nameType": "text",
"makeDisplay": "text"
}
]
]
I want to convert it to an object, but the problem is that I have nested arrays and the solution below doesn't work;
private var items: List<CarModel> = emptyList()
items = Json(JsonConfiguration.Stable).parse(CarsResponse.serializer().list, "MiJSON.json ....")
@Serializable
data class CarsResponse(
val items: List<ItemsModels> = emptyList()
)
@Serializable
data class ItemsModels(
val items: List<CarModel> = emptyList()
)
@Serializable
data class CarModel(
val body: String = EMPTY_STRING,
val bodyType: String = EMPTY_STRING,
val nameType: String = EMPTY_STRING,
val makeDisplay: String = EMPTY_STRING
)