-1

在 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?
}
4

1 回答 1

1

问题是Array<Any>. 您需要一些可解码类型的数组,例如 String 或 Int。

于 2018-04-08T21:54:33.700 回答