Я пытаюсь получить данные от JSON
с помощью Alamofire
, но данные приходят с ["Chris Martin"], а не с Chris Martin. Проверьте это изображение
Вот мой код
@IBAction func botaoSalvar(_ sender: Any) {
let nomeUsuario = self.campoUsuario.text;
let cpf = self.campoCPF.text;
let senha = self.campoSenha.text;
let param = ["nome": nomeUsuario, "cpf": cpf, "senha": senha, "method": "app-set-usuario"]
var _: HTTPHeaders = ["Content-Type": "application/json"]
let url = "http://easypasse.com.br/gestao/wsCadastrar.php"
Alamofire.request(url, method:.post, parameters:param,encoding: JSONEncoding.default).responseJSON { response in
switch response.result {
case .success:
//print(response)
let json = JSON(response.result.value as Any)
let idusuario = json["usuario"].arrayValue.map({$0["idUsuario"].stringValue})
let nome = json["usuario"].arrayValue.map({$0["nome"].stringValue})
let cpf = json["usuario"].arrayValue.map({$0["cpf"].stringValue})
print(idusuario)
print(nome)
print(cpf)
case .failure(let error):
print(0,"Error")
}
}
Как мне это исправить?
Спасибо.