Praveen Kumar
07/06/2023, 7:09 AMhttps://cmms.auswegprime.com/attachments/employee/placeholder.jpg▾
Tóth István Zoltán
07/06/2023, 8:20 AMPraveen Kumar
07/06/2023, 9:30 AMimplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
am using this library for serializationPraveen Kumar
07/06/2023, 9:42 AMAleksei Tirman [JB]
07/06/2023, 9:50 AMPraveen Kumar
07/06/2023, 9:51 AMclass GetProductsUseCase: BaseUseCase<String, ArrayList<Engine>>() {
override suspend fun execute(plant_id: String): ArrayList<Engine> {
val response = <http://networkClient.post|networkClient.post>("<https://cmms.auswegprime.com/Api/get_plant_engineer_status_list>")
return response.body()
}
}
hereAleksei Tirman [JB]
07/06/2023, 9:56 AMArrayList
but the JSON's root element is an object.Aleksei Tirman [JB]
07/06/2023, 9:57 AMPraveen Kumar
07/06/2023, 9:58 AMclass GetProductsUseCase: BaseUseCase<String, List<Engine>>() {
override suspend fun execute(plant_id: String): List<Engine> {
val response = <http://networkClient.post|networkClient.post>("<https://cmms.auswegprime.com/Api/get_plant_engineer_status_list>")
return response.body()
}
}
now, its right?Aleksei Tirman [JB]
07/06/2023, 10:03 AMkotlinx.serialization
framework to get a better understanding of how the mapping works.Praveen Kumar
07/06/2023, 10:07 AMAndromadus Naruto
07/06/2023, 7:52 PMList<Engine>
within a data class with a property named data
Example:
data class ApiResponse<T>(
val iserror: Boolean,
val message: String,
val data: T,
)
class GetProductsUseCase: BaseUseCase<String, List<Engine>>() {
override suspend fun execute(plant_id: String): List<Engine> {
val response = <http://networkClient.post|networkClient.post>("<https://cmms.auswegprime.com/Api/get_plant_engineer_status_list>")
return response.body<ApiResponse<List<Engine>>>().data
}
}