Avatar
@JohnLight The JSON lacks some properties of Utilisateur. If they are optional, you need them as Optionals. import Foundation struct Utilisateur: Codable { let id: Int let solde: Solde let soldecrypto: Soldecrypto let nom: String let prenom: String let adresse: String? let ipadresse: String let codepostale: String? let ville: String? let reference: String let cgv: Int let genre: String let telephone: String let password: String let password_reset: String let password_updated: String let email: String let username: String let active: Int let iban: String? let bic: String? let load_identite: String? let load_justificatif_domicile: String? let validated: Int let roles: String let datenaissance: String let created: String } struct Solde: Codable { let id: Int let solde: Double let solde_old: Double let updated: String } struct Soldecrypto: Codable { let id: Int let bch_solde: Double let btc_solde: Double let eos_solde: Double let etc_solde: Double let eth_solde: Double let ltc_solde: Double let xrp_solde: Double let zec_solde: Double let updated: String } let url = URL(string: "https://preprod.cryptizy.com/test_bs78wazerty1235436ujYH/users")! let jsonData = try! Data(contentsOf: url) let decoded = try! JSONDecoder().decode([Utilisateur].self, from: jsonData) print(decoded) (edited)
3:07 AM
For example, I changed the type of adresse from String to String?.
3:07 AM
I have no idea about if the JSON is corrupted or those properties are really optional.