尝试在另一个数组中使用可解码结构时出现可解码错误

getting decodable error when trying to use decodable struct in another as array

我遇到可解码错误:不符合可解码...

用于:

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 does not conform to Decodable

为什么?以及如何解决?

应该是这样的,

struct Root2 : Decodable {
    let services : [Services]
    let nationalities : [Nationalities]
    let packages : [Packages]
}

查看 NationalityNationalities

之间的区别