So, I have given an API that returns this on a POST call
{
"JHK":"One piece",
"LKJ":"Two pieces",
"OEN":"Three pieces"
}
And since this is a list but is not good formated from the backend I dont know how to get it from Android, this is what I have tried
WebService
@POST("get_user_codes.php")
suspend fun getUserCodesByMemberId(@Body member_id:String): CodesResponse
CodesResponse
data class CodesResponse(val data: List<Code>)
data class Code(val code_id:String,val name:String)
Repository
suspend fun getUserCodes(memberId:String):Result<CodesResponse>{
return Result.Success(webService.getUserCodesByMemberId(memberId))
}
But his is outping Null as the response, I really dont know how to bring those different objects that are supposed to be an array of object but instead they are all inside one object
Any idea ?
API INPUTS
member_id as text string
Example of input:
{ "member_id": "1"}
API OUTPUTS
code_id: as a String
name: as a String
{
"JHK":"One piece",
"LKJ":"Two pieces",
"OEN":"Three pieces"
}
EDIT
the values can be more than those 3 I posted, it depends on how many the response returns