Newer
Older
import Foundation
public struct Fact: Equatable {
public init(
fact: String,
type: Int
) {
self.fact = fact
self.type = type
}
public var fact: String
public var type: Int
}
extension Fact: Codable {
enum CodingKeys: String, CodingKey {
case fact = "Fact"
try JSONDecoder().decode(Self.self, from: data)
}
try JSONEncoder().encode(self)
}
}
extension Array where Element == Fact {
try JSONDecoder().decode(Self.self, from: data)
}
try JSONEncoder().encode(self)
}
}