Вот тут json:
{
"article": [
{
"header": "mindshare payment",
"items": [
{
"title": "Applications workforce",
"text": "Nulla molestiae aliquid natus libero placeat fugit recusandae tempora et."
}
]
}
]
}
Вот пример моего кода:
if let result = response.result.value as? [String: Any],
let articleArray = result["article"] as? [[String: Any]],
let main = articleArray["items"] as? [[String: Any]] {
for obj in main {
guard
let title = obj["title"] as? String,
let text = obj["text"] as? String,
else {
return
}
let struct = Articles(title: title, text: text)
}
}
Появляется ошибка: Cannot subscript a value of type '[[String : Any]]' with an index of type 'String'