我遇到了可解码的错误:不符合Decodable ......
有:
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不符合Decodable
为什么呢?以及如何解决它?
答案 0 :(得分:0)
应该是这样的,
struct Root2 : Decodable {
let services : [Services]
let nationalities : [Nationalities]
let packages : [Packages]
}
查看Nationality
&之间的区别Nationalities