I have the json
{
"message": null,
"data": {
"Commodity Department": {
"total": 2,
"completed": 1,
"completedWithDue": 0,
"completedWithOutDue": 1,
"inProgress": 1,
"inProgressWithDue": 0,
"inProgressWithOutDue": 1,
"statusCounter": null
}
}
I need to convert the each department json object to array. Currently each category value ("total": 0, "completed": 0, "completedWithDue": 0, "completedWithOutDue": 0, "inProgress": 0, "inProgressWithDue": 0, "inProgressWithOutDue": 0,)
will be in object format. I need to convert in array and load to collectionview based on category. As of now I am trying to decode my json in the below code
public struct Dashboard: Decodable {
public let data : [String:Departments]
}
public struct Departments: Decodable {
public let total, completed, completedWithDue, completedWithOutDue: Int
public let inProgress, inProgressWithDue, inProgressWithOutDue: Int
}
let dashboard = try? JSONDecoder().decode(Dashboard.self, from: response.data!)
print(dashboard!.data.keys)