I have these Models :
struct City: Decodable {
let famous: Flags
let name: Name
}
struct Name: Decodable {
var common , official : String
var nativeName: [String:NativeName]
enum CodingKeys: String, CodingKey {
case common, official
case nativeName = "nativeName"
}
struct NativeName: Codable {
let official, common: String
enum CodingKeys: String, CodingKey {
case official, common
}
Decoding command:
let content = try? decoder.decode([Cities].self, from: data)
as soon as comment the var nativeName: [String:NativeName] line everyThing is okay
how can I sterilize?
try?, use a properdo/try/catchto get the error that will tell you exactly what failed, and share also the JSON. We can't guess what's wrong with your code with the given content of your question. Maybe line 3 in second file?https://app.quicktype.io/and make a model from here and rename thestructures. you can try and let me know your outcome