我正在进入可解码的错误:不符合可解码.
适用于:
struct Packages : Decodable {
let id: Int
let name: String
let idService: Int
let nationality: String
let totalPrice: Int
let visitsPerWeek: Int
let pricePerVisit: Int
let excludedDays: String
let excludedShifts: String
let excludedDates: String
let extraVisits: Int
let dateEnabled: String
let dateDisabled: String
let allowedFrom: String
let allowedTo: String
let visitType: String
let createdAt: String?
let updatedAt: String?
}
struct Nationalities : Decodable{
let id: Int
let name: String
let createdAt: String?
let updatedAt: String?
}
struct Services : Decodable{
let id: Int
let name, description: String
let createdAt: String?
let updatedAt: String?
}我在这里用它就像:
struct Root2 : Decodable {
let services : [Services]
let nationalities : [Nationality]
let packages : [Packages]
}我得到的是:
Root2不符合可解码
为什么?以及如何解决这个问题?
发布于 2018-04-26 09:38:29
应该是这样的,
struct Root2 : Decodable {
let services : [Services]
let nationalities : [Nationalities]
let packages : [Packages]
}看到Nationality和Nationalities之间的区别
https://stackoverflow.com/questions/50039555
复制相似问题