@
chiaf 这种 Codable 也可以解决, 但实际上是后端的问题
```swift
public enum EitherOr<T, V>: Codable where T: Codable, V: Codable {
case either(T)
case or(V)
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let value = try? container.decode(T.self) {
self = .either(value)
} else if let value = try? container.decode(V.self) {
self = .or(value)
} else {
throw DecodeError.unkownType
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .or(value): try container.encode(value)
case let .either(value): try container.encode(value)
}
}
public var either: T? {
switch self {
case let .either(v): return v
default: return nil
}
}
public enum DecodeError: Error {
case unkownType
}
}
```