12 lines
296 B
Swift
12 lines
296 B
Swift
extension KeyedDecodingContainer {
|
|
public func decodeFloatOrString(forKey key: Key) throws -> Float? {
|
|
if let floatVal = try? decode(Float.self, forKey: key) {
|
|
return floatVal
|
|
}
|
|
if let stringVal = try? decode(String.self, forKey: key) {
|
|
return Float(stringVal)
|
|
}
|
|
return nil
|
|
}
|
|
}
|