You have to write a custom initializer. First decode a dictionary, if it fails decode an array
struct Predictions : Decodable {
let predictions: [Prediction]
let copyright: String
private enum CodingKeys: String, CodingKey { case predictions, copyright }
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
copyright = try container.decode(String.self, forKey: .copyright)
do {
let prediction = try container.decode(Prediction.self, forKey: .predictions)
predictions = [prediction]
} catch DecodingError.typeMismatch {
predictions = try container.decode([Prediction].self, forKey: .predictions)
}
}
}