更新时间:2021-08-23 00:28:20
只是您的Album
模型不正确.
struct Album: Codable {
var source : Source
var id : String
enum CodingKeys: String, CodingKey {
case source = "_source"
case id = "_id"
}
}
struct Source: Codable {
var nome : String
var endereco : String?
var uf : String?
var cidade : String?
var bairro : String?
}
如果您不希望完全使用_id
,则只需删除相关部分.
至于与Alamofire
相关的代码,那部分很好.
If you don't want _id
altogether then simply remove the related parts.
As for your Alamofire
related code, that part is good.
显着改进:
CodingKeys
以实现键映射目的,避免了模型中带下划线的变量名_source
为Source
)
CodingKeys
for key mapping purpose_source
is Source
)