I have JSON structure as:
\"periods\": {
\"2018-06-07\": [
{
\"firstName\": \"Test1\",
\"lastName\": \"Test1\"
}
I think the JSON shall be appended with {
at the beginning and }
at the end in order to be valid JSON, then you can easily extract periods with code like that:
struct Period: Decodable {
let firstName: String, lastName: String
}
let schedule = try? JSONDecoder().decode([String:[String:[Period]]].self, from: jsonData!)
let periods = schedule?.values.first?.values