struct family: Decodable {
let userId: [String:Int]
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let url = "http://supinfo.steve-colinet.fr/supfamily?action=login&username=admin&password=admin"
let urlobj = URL(string: url)
URLSession.shared.dataTask(with: urlobj!){(data, response, error) in
do{
let member = try JSONDecoder().decode(family.self, from: data!)
print(member)
}catch{
print(error)
}
}.resume()
}
}
Error:
keyNotFound(CodingKeys(stringValue: "userId", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"userId\", intValue: nil) (\"userId\").", underlyingError: nil))