我目前正在从我的 json 中获取我想要的所有数据,但我想添加不是来自 json 的额外变量。
struct LoanUser: Codable {
let name: String
let use: String
let location: Location
let loan_amount: Int
let image: Image
var favorite: Bool = false
}
var 收藏夹:bool = false 不是 json 字符串。这是我想要添加的额外变量
您必须自己指定编码键,并且不包括收藏夹
struct LoanUser: Codable {
let name: String
let use: String
let location: Location
let loan_amount: Int
let image: Image
var favorite: Bool = false
enum CodingKeys: String, CodingKey {
case name, use, location, loan_amount, image
}
}