struct AllImage: Codable {
let mediaReferenceID: String?
let url: String?
let title: String?
let description: String?
let icon: String?
let tags: [TagInfo]?
let footerSection: FooterSection?
enum CodingKeys: String, CodingKey {
case mediaReferenceID = "media_reference_id"
case url, title, description, icon
case ctaInfo = "cta_info"
case footerSection = "footer_section"
}
}
这里TagInfo
和FooterSection
也是可编码的,只包含字符串类型。
这个问题有什么解决办法吗?
1条答案
按热度按时间h7appiyu1#
CodingKeys应该反映该类型的所有属性,继承Codable,不能有额外的字段。因此,您还应该添加标记并删除ctaInfo。