Есть JSON в таком виде:
{
"trainDay": "1 DAY:",
"nameOfMuscle": "Chest and Triceps",
"trainInfo": [
{
"exerciseImage": "https://www.got-big.de/Blog/wp-content/uploads/2017/04/Bankdruecken-Bench-Press.jpg",
"exerciseName": "Bench Press",
"numberOfSets": "4-5",
"numberOfRepeats": "8-12",
"restTime": "120-180"
},
{
"exerciseImage": "https://i.ytimg.com/vi/0aZS8czIj1I/maxresdefault.jpg",
"exerciseName": "Incline Bench Press",
"numberOfSets": "3-4",
"numberOfRepeats": "8-12",
"restTime": "120-180"
},
{
"exerciseImage": "https://i.ytimg.com/vi/3-ZigiOoU3o/maxresdefault.jpg",
"exerciseName": "Inclined Dumbbell Press",
"numberOfSets": "3-4",
"numberOfRepeats": "8-12",
"restTime": "120-180"
},
{
"exerciseImage": "https://crossi.ru/wp-content/uploads/1/1/0/1101845a533f9f59ba26d48d2779059f.jpeg",
"exerciseName": "Overhead Burbel Extension",
"numberOfSets": "3-4",
"numberOfRepeats": "8-12",
"restTime": "60-120"
},
{
"exerciseImage": "https://homegymreview.co.uk/wp-content/uploads/exercises/02001101-Cable-Pushdown-with-rope-attachment_Upper-Arms_max-scaled.jpg",
"exerciseName": "Rope Pushdown",
"numberOfSets": "3-4",
"numberOfRepeats": "8-12",
"restTime": "60-120"
}
]
}
Моя модель выглядит так, но при выводе результата улетает в ошибку
struct NoteExercise: Decodable {
let trainDay: String
let nameOfMuscle: String
let trainInfo: TrainInfo
}
struct TrainInfo: Decodable {
let exerciseImage: URL
let exerciseName: String
let numberOfSets: String
let numberOfRepeats: String
let restTime: String
}
В онлайн сервисе JSON парсится.