类型“ResultModel”不符合协议“Decodable”
我找不到这个问题的原因。我已经添加了整个模块模型 Codable 代码,但无法在 ResultsModel 中找到导致问题的确切原因。
import Foundation
// MARK: - Welcome
struct Welcome: Codable {
let response: Responses
enum CodingKeys: String, CodingKey {
case response
}
}
// MARK: - Response
struct Responses: Codable {
let requestID: String
let code: Int
let results: ResultsModel
enum CodingKeys: String, CodingKey {
case requestID = "requestId"
case results = "ResultsModel"
case code
}
}
// MARK: - Result
struct ResultsModel: Codable {
let propertyTimeZone: [PropertyTimeZoneModel]
let maintenanceLocations: [MaintenanceLocation]
let maintenanceActions: [MaintenanceAction]
let maintenanceProblems: [MaintenanceProblemModel]
let maintenanceCategories: [MaintenanceCategoryModel]
let maintenanceStatuses: [MaintenanceStatusModel]
let maintenanceRequestTypes: [MaintenanceRequestType]
let maintenancePriorityTypes: [MaintenancePriorityType]
let maintenanceLocationTypes: [MaintenanceLocationType]
let assignedToUsers: [AssignedToUserModel]
let maintenanceStatusTypes: [MaintenanceStatusType]
let inspectionStatuses: [InspectionStatusModel]
let inspectionTypes: [InspectionType]
let userPermissions: [UserPermissionModel]
let userAssignedProperties: [UserAssignedProperty]
let maintenanceTemplates: [MaintenanceTemplateModel]
let propertyBuildingData: [PropertyBuildingDatum]
let lastSyncOn: Int
enum CodingKeys: String, CodingKey {
case propertyTimeZone, maintenanceLocations, maintenanceActions, maintenanceProblems, maintenanceCategories, maintenanceStatuses, maintenanceRequestTypes, maintenancePriorityTypes, maintenanceLocationTypes, assignedToUsers, maintenanceStatusTypes, inspectionStatuses, inspectionTypes, userPermissions, userAssignedProperties, maintenanceTemplates, propertyBuildingData
case lastSyncOn
}
}
// MARK: - AssignedToUser
struct AssignedToUserModel: Codable {
let id: Int
let nameFirst, nameLast, nameFull: String
let propertyID, companyUserID: Int
let includeInMaintenanceRequest, includeInInspection: Bool?
enum CodingKeys: String, CodingKey {
case id, nameFirst, nameLast, nameFull
case propertyID = "propertyId"
case companyUserID = "companyUserId"
case includeInMaintenanceRequest, includeInInspection
}
}
// MARK: - InspectionStatus
struct InspectionStatusModel: Codable {
let statusID: Int
let statusName: String
enum CodingKeys: String, CodingKey {
case statusID = "statusId"
case statusName
}
}
// MARK: - InspectionType
struct InspectionType: Codable {
let inspectionTypeID: Int
let inspectionTypeName: String
enum CodingKeys: String, CodingKey {
case inspectionTypeID = "inspectionTypeId"
case inspectionTypeName
}
}
// MARK: - MaintenanceAction
struct MaintenanceAction: Codable {
let propertyID, companyActionID, propertyActionID, actionTypeID: Int
let actionName: String
let orderNum: Int
let isPublished: Bool
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case companyActionID = "companyActionId"
case propertyActionID = "propertyActionId"
case actionTypeID = "actionTypeId"
case actionName, orderNum, isPublished
}
}
// MARK: - MaintenanceCategory
struct MaintenanceCategoryModel: Codable {
let propertyID, companyCategoryID: Int
let categoryName: String
let isPublished: Bool
let problemList: [Int]?
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case companyCategoryID = "companyCategoryId"
case categoryName, isPublished, problemList
}
}
// MARK: - MaintenanceLocationType
struct MaintenanceLocationType: Codable {
let maintenanceLocationTypeID: Int
let maintenanceLocationTypeName: String
enum CodingKeys: String, CodingKey {
case maintenanceLocationTypeID = "maintenanceLocationTypeId"
case maintenanceLocationTypeName
}
}
// MARK: - MaintenanceLocation
struct MaintenanceLocationModel: Codable {
let propertyID, propertyLocationID, companyLocationID: Int
let locationName: String
let orderNum: Int
let isPublished: Bool
let maintenanceLocationTypeID: Int
let problemList: [Int]?
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case propertyLocationID = "propertyLocationId"
case companyLocationID = "companyLocationId"
case locationName, orderNum, isPublished
case maintenanceLocationTypeID = "maintenanceLocationTypeId"
case problemList
}
// MARK: - MaintenancePriorityType
struct MaintenancePriorityType: Codable {
let maintenancePriorityTypeID: Int
let maintenancePriorityTypeName: String
enum CodingKeys: String, CodingKey {
case maintenancePriorityTypeID = "maintenancePriorityTypeId"
case maintenancePriorityTypeName
}
}
// MARK: - MaintenanceProblem
struct MaintenanceProblemModel: Codable {
let propertyID, propertyProblemID, companyProblemID: Int
let problemName: String
let orderNum: Int
let isPublished, useInWorkOrder, useInInspection, isIntegrated: Bool
let actionList: [Int]
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case propertyProblemID = "propertyProblemId"
case companyProblemID = "companyProblemId"
case problemName, orderNum, isPublished, useInWorkOrder, useInInspection, isIntegrated, actionList
}
}
// MARK: - MaintenanceRequestType
struct MaintenanceRequestType: Codable {
let maintenanceRequestTypeID: Int
let maintenanceRequestTypeName: String
enum CodingKeys: String, CodingKey {
case maintenanceRequestTypeID = "maintenanceRequestTypeId"
case maintenanceRequestTypeName
}
}
// MARK: - MaintenanceStatusType
struct MaintenanceStatusType: Codable {
let maintenanceStatusTypeID: Int
let maintenanceStatusTypeName: String
enum CodingKeys: String, CodingKey {
case maintenanceStatusTypeID = "maintenanceStatusTypeId"
case maintenanceStatusTypeName
}
}
// MARK: - MaintenanceStatus
struct MaintenanceStatusModel: Codable {
let propertyID, propertyStatusID, companyStatusID: Int
let statusName: String
let orderNum, maintenanceStatusTypeID: Int
let isPublished: Bool
let isDefault: Bool?
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case propertyStatusID = "propertyStatusId"
case companyStatusID = "companyStatusId"
case statusName, orderNum
case maintenanceStatusTypeID = "maintenanceStatusTypeId"
case isPublished, isDefault
}
}
// MARK: - MaintenanceTemplate
struct MaintenanceTemplateModel: Codable {
let propertyID, maintenanceTemplateID: Int
let templateName: String
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case maintenanceTemplateID = "maintenanceTemplateId"
case templateName
}
}
// MARK: - PropertyBuildingDatum
struct PropertyBuildingDatum: Codable {
let propertyID, buildingID: Int
let buildingName: String
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case buildingID = "buildingId"
case buildingName
}
}
// MARK: - PropertyTimeZone
struct PropertyTimeZoneModel: Codable {
let propertyID: Int
let timeZoneName, timeZoneAbbr, gmtOffset: String
let isDaylightSavings: Bool
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case timeZoneName, timeZoneAbbr, gmtOffset, isDaylightSavings
}
}
// MARK: - UserAssignedProperty
struct UserAssignedProperty: Codable {
let propertyID: Int
let propertyName: String
let isIntegrated: Bool
let propertyPreferences: [PropertyPreferenceModel]
let boolIsAccessInspectionManager: Bool
enum CodingKeys: String, CodingKey {
case propertyID = "propertyId"
case propertyName, isIntegrated, propertyPreferences, boolIsAccessInspectionManager
}
}
// MARK: - PropertyPreference
struct PropertyPreferenceModel: Codable {
let preference, value: String
}
// MARK: - UserPermission
struct UserPermissionModel: Codable {
let permission: String
let value: Int
}