我在swift4中使用JSONDecodable时遇到以下错误。 "Type UserRegister does not confirm to protocol 'Decodable' "
我的模型结构看起来像这样。
struct UserRegister: Decodable {
let id : NSInteger
let name : String?
let email : String?
let cities : Array<Any>?
let tax : [tax]
let username : [username]
}
struct tax : Decodable {
let deviceId : NSInteger?
let financialYear : String?
let country : String?
let name : String?
let state : String?
let taxCode : String?
let value : NSInteger?
}
struct username : Decodable {
let email : String?
let phone : String?
}
答案 0 :(得分:1)
问题是Array<Any>
。您需要一些Decodable类型的数组,例如String或Int。