import Foundation extension Decodable { init?(jsonData: Data) { guard let value = try? JSONDecoder().decode(Self.self, from: jsonData) else { return nil } self = value } init?(jsonString: String) { guard let data = jsonString.data(using: .utf8) else { return nil } self.init(jsonData: data) } }