I'm attempting to parse the following json schema, poster may or may not be empty
{
"poster": {},
"recommends": []
}
My decodable classes are as follows:
public struct RecommendedList: Decodable {
public let poster: Poster?
public let recommends: [Recommend]
}
public struct Poster: Decodable {
public let backgroundImage: URL
public let topImage: URL
public let windowImage: URL
public let windowSkinImagePath: URL
public let deeplink: URL
public init(from decoder: Decoder) throws {
// I want a failable intializer not one that throws
}
}
My question is how do I make poster optional? My thought was I would need a failable initializer, but decodable requires a init that throws.