extension Array where Element: Encodable { /// - Returns: An array having removed any element of the array which is not encodable itself. func filterUncodable() -> [Element] { return self.filter { (el: Element) -> Bool in let encoded = try? JSONEncoder().encode(el) return encoded != nil ? true : false } } }