Created
November 24, 2021 16:40
-
-
Save homerblr/a2c36fc66ffca664a45fecb585793d16 to your computer and use it in GitHub Desktop.
some fix for boa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NBLLiveBoxScoreTeamTotalCoverAPIModel: Codable { | |
let team: BoxScoreTeamTypeEnum? | |
let players: [NBLLiveBoxScoreAPIModel]? | |
enum BoxScoreTeamTypeEnum: Codable { | |
case object(NBLLiveBoxScoreTeamAPIModel?) | |
case array(Array<NBLLiveBoxScoreTeamAPIModel>) | |
init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
do { | |
self = .array(try container.decode([NBLLiveBoxScoreTeamAPIModel].self)) | |
} catch DecodingError.typeMismatch { | |
self = .object(try container.decode(NBLLiveBoxScoreTeamAPIModel.self)) | |
} | |
func encode(to encoder: Encoder) throws { | |
var container = encoder.singleValueContainer() | |
switch self { | |
case .object(let value): | |
try container.encode(value) | |
case .array(let value): | |
try container.encode(value) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment