This is quite ugly but to can help you. The new structure read the new JSON but return the previous interface
`// Old structure
struct ContactMediumOld: Codable {
struct ContactMedium: Codable {
var type: String
struct Characteristic: Codable {
var emailAddress : String
}
var characteristic: Characteristic
}
var contactMedium: [ContactMedium]
}
// New structure
struct ContactMediumNew: Codable {
struct ContactMedium: Codable {
var type: String
struct Characteristic: Codable {
var emailAddress : String
}
// name of property also changed so use a computed for old name
private var characteristics: Characteristic
var characteristic: Characteristic {
characteristics
}
}
// read an simple object
private var contactMediumNew: ContactMedium
enum CodingKeys: String, CodingKey {
case contactMediumNew = "contactMedium"
}
// but return an array
var contactMedium: [ContactMedium] {
[contactMediumNew]
}
}`