我从这种类型的服务器得到一个响应,其中该对的名称是关键:
{
"BTC_BCN":{
"last":"0.00000057",
"percentChange":"0.03636363",
"baseVolume":"47.08463318"
},
"BTC_BELA":{
"last":"0.00001281",
"percentChange":"0.07376362",
"baseVolume":"5.46595029"
}
}
如何将其解码为属性名称是json的键的结构:
struct Pair: Codable {
let name: String // need to put the name of the pair ("BTC_BCN")
let last: String
let percentChange: String
let baseVolume: String
}