struct JsonReposne: Decodable {
let events: [Event]
static func decode(_ json: Any) throws -> JsonReposne {
return try JsonReposne(
events: json // but this will not work
)
}
}
Workaround is to put JSON into dictionary and pass that dictionary
static func decode(_ json: Any) throws -> JsonReposne {
let data = ["data": json] as Any
return try JsonReposne(
events: data => "data"
)
}
So many times I did have situations with JSONs
For example json with Events
So decoded struct should look like
Workaround is to put JSON into dictionary and pass that dictionary
Maybe this is worth adding to Decodable itself?