Вот мой код, я получаю ответ и хочу использовать некоторые значения в этом
Я написал так, но ошибка идет
let id = json["emp_id"] as! [String:Any]
let parameters = [
"email": empEm,
"password":"1234"
] as [String : Any]
guard let url = URL(string: "http://localhost:8080/company/employee/login") else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
guard let httpBody = try? JSONSerialization.data(withJSONObject: parameters, options: []) else { return }
request.httpBody = httpBody
let session = URLSession.shared
session.dataTask(with: request) { (data, response, error) in
if let response = response {
print(response)
}
if let data = data {
do {
let json = try JSONSerialization.jsonObject(with: data, options: [])
print(json)
let id = json["emp_id"] as! [String:Any]
} catch {
print(error)
}
}
}.resume()
мой ответ
{
available = 3;
compoff = 0;
displayname = Vamsi;
"emp_id" = 001;
gender = Male;
id = 1;
leaves = 4;
rating = 0;
star = 0;
"termination_date" = active;
wfh = 0;
}
Я хочу взять подробности, такие как id, emp_id из ответа