So I was trying JSON parsing with Decodable and the fields of the Decodable struct should match with their names in JSON but there's an object in JSON which has a "-" in its name. How do I name the field in the Struct?
JSON:
"media-metadata": [
{
"format": "Standard Thumbnail",
"height": 75,
"width": 75
},
{
"format": "mediumThreeByTwo440",
"height": 293,
"width": 440
}
]
Code:
struct MediaMetadataDetails: Decodable {
let format: String
let height: Int
let width: Int
}
struct MediaObject: Decodable {
let media-metadata: [MediaMetadataDetails] // ???
}