Я пытаюсь проанализировать вложенные данные из ответа JSON, но не добился успеха. Ниже приведено то, что я пробовал до сих пор, и ответ json пытается разобрать.
// JSON
{
"statusCode": 200,
"success": true,
"data": {
"tDetail": [
{
"roleId": null,
"id": 34,
"userId": 126,
"catId": null,
"importId": null,
"name": "My task from postman",
"myday": 1,
"important": 0,
"completed": 0,
"dateCreated": "2020-02-10T09:05:04.000Z",
"dateModified": "2020-02-10T09:05:04.000Z"
}
],
"steps": [],
"files": [],
}
}
// Struct
struct MyDayAndTaskDetails: Codable
{
let data : [MyTaskDetail]
}
struct MyTaskDetail : Codable {
let roleId, taskId, userId, catId, important, completed, recurring, myday : Int?
let repeatType, name, duedate, reminder, frequency, weekdays, notes, baseurl : String?
let steps : [Steps]
let files : [Files]
private enum CodingKeys: String, CodingKey {
case taskId = "id"
case userId = "userId"
case roleId = "roleId"
case catId = "catId"
case myday = "myday"
case name = "name"
case notes = "notes"
case duedate = "duedate"
case reminder = "reminder"
case recurring = "recurring"
case repeatType = "repeatType"
case important = "important"
case completed = "completed"
case frequency = "frequency"
case weekdays = "weekdays"
case baseurl = "baseurl"
case steps = "Steps"
case files = "Files"
}
}
struct Steps : Codable {
let stepName : String?
let status, stepId : Int?
private enum CodingKeys: String, CodingKey {
case stepName = "stepName"
case status = "status"
case stepId = "stepId"
}
}
struct Files : Codable {
let fileName : String?
private enum CodingKeys: String, CodingKey {
case fileName = "fileName"
}
}