Skip to content

Instantly share code, notes, and snippets.

View muhammadbassio's full-sized avatar

Muhammad Bassio muhammadbassio

View GitHub Profile
import SwiftyJSON
extension JSON {
func parseTo<T: Codable>() -> T? {
guard let data = try? rawData(options: .prettyPrinted) else {
return nil
}
let decoder = JSONDecoder()
return try? decoder.decode(T.self, from: data)
}