Hot to decode JSON data that could and array or a single element in Swift?
问题 I have a struct named Info which is decoded based on the data it receives. But sometimes, one of the values in data can either be a double or an array of double. How do I set up my struct for that? struct Info: Decodable { let author: String let title: String let tags: [Tags] let price: [Double] enum Tags: String, Decodable { case nonfiction case biography case fiction } } Based on the url, I either get price as a double { "author" : "Mark A", "title" : "The Great Deman", "tags" : [