I'm trying to parse the ResponseBody json object. I then need to create a WarehouseList array of Warehouse objects. Here is my response json.
{
"GetUserWarehouseListResult": [
{
"Message": null,
"WarehouseId": 31232,
"WarehouseName": "ABQ"
},
{
"Message": null,
"WarehouseId": 22113,
"WarehouseName": "AMS"
},
{
"Message": null,
"WarehouseId": 21645,
"WarehouseName": "ORD"
}
}
In objective-c, I can do this with below:
for (NSDictionary* element in [dictionary objectforKey:@"GetUserWarehouseListResult"]) {
}
However, I need help doing this in Kotlin with RetroFit2
Here is my current code:
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
val stringResponse = response.body()?.string()
Log.d(TAG,"Response: " + stringResponse)
}