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 } public func decodeStringOrInt(forKey key: Key) throws -> Int? { if let intVal = try? decode(Int.self, forKey: key) { return intVal } if let stringVal = try? decode(String.self, forKey: key) { return Int(stringVal) } return nil } }