Я получил ответ от json и хочу получить его для своей переменной, но в ответе нет массива
{
"status": true,
"msg": "Login berhasil. username=081xxxxxx reg_id=",
"id_user": {
"no": "349",
"nama_teknisi": "Putra Utama",
"telp_teknisi": "081xxxxx"
}
}
У меня есть код, но все равно ошибка, это мой код:
Alamofire.request(URL_USER_LOGIN, method: .get).authenticate(user: username!, password: password!).responseJSON { response in
if let error = response.error{
self.hideLoading()
return
}
debugPrint(response.result.value!)
let parsedResult = JSON(response.result.value!)
var successed:Bool = true
if let success = parsedResult["status"].bool{
successed = success
}
if successed {
OperationQueue.main.addOperation {
print("success")
self.hideLoading()
let id_user = parsedResult["id_user"].array
for id_item in id_user! {
self.lbnama.append(id_item["nama_teknisi"].string!)
self.lbtelp.append(id_item["telp_teknisi"].string!)
self.keychain.set(self.lbnama, forKey: "nama_key")
self.keychain.set(self.lbtelp, forKey: "telp_key")
print(self.keychain.get("nama_key"))
}
}
} else {
print("error")
}
}
и это моя ошибка
![enter image description here](https://i.stack.imgur.com/DgNyX.png)