Hello I'm new in Swift and I try to write a parser for json through extension with JsonSerialization
I want to implement a function to parse json file and in the same extension to implement the computable var json, which will form json
// Model
struct Todoitem {
let id = {
return UUID().uuidString
}()
let text : String
let importance : Importance
let deadline : Date?
}
enum Importance {
case usual, important, unimportant
}
//Parser
extension Todoitem {
static func parse(json : Any) -> Todoitem? {
if let file = try? JSONSerialization.jsonObject(with: json) as? [String : Any] {
}
return nil
}
}