I have successfully received some JSON. Ran it through JSONSerialization and created a dictionary from. I can access any key: value pair but I can't seem to access a key with what I want to call nested properties/objects. I am new to Swift so I am unsure of terminology. Anyways here is an example of the key I want to access.
"videos": {
mp4 = {
1080 = "https://videos.kaiserclix.com/AVideo/videos/_YPTuniqid_6061fbc1c89a53.50466226_1080.mp4";
240 = "https://videos.kaiserclix.com/AVideo/videos/_YPTuniqid_6061fbc1c89a53.50466226_240.mp4";
360 = "https://videos.kaiserclix.com/AVideo/videos/_YPTuniqid_6061fbc1c89a53.50466226_360.mp4";
480 = "https://videos.kaiserclix.com/AVideo/videos/_YPTuniqid_6061fbc1c89a53.50466226_480.mp4";
};
Here is the chunk of swift I would have thought found what I want:
if let link = movieDict["videos.mp4"]?["480"] as? String? {
print(link)
self.videoLink = link
}
Here is the swift file containing the structs:
class Movie{
struct Welcome: Codable {
let error: Bool
let message: String
let response: Response
}
struct Response: Codable {
let totalRows: Int
let rows: [Row]
}
struct Row: Codable {
let title, cleanTitle: String
let videos: Videos
let poster, thumbnail: String
}
struct videos: Codable {
let vides: [String: String]
}
enum TypeEnum: String, Codable {
case video = "video"
}
struct Videos: Codable {
let mp4: [String: String]
}
var title : String!
var posterPath : String!
var videoLink : String!
Please help! I have been banging my head against the wall!
Thanks!
Greg