i am using Urlsession and JSONDecoder to get and decode my data but somehow some variables on Weather struct returns nil while im decoding it. it may be something related to utf8 but I can't figure out how to handle.
var request = URLRequest(url: URL(string: "myurlstring")
URLSession.shared.dataTask(with: request) {(data,resp,err) in
guard let data = data else { return }
do{
let decoder = JSONDecoder()
let weatherData = try decoder.decode(Weather.self, from: data)
completion(weatherData,nil)
} catch let err {
completion(nil,err)
}
}.resume()
im getting nil values as you can see here:
but on postman I can get non nil results
This is the raw json data that I get from postman
{"lat":39.92,"lon":32.85,"timezone":"Europe/Istanbul","timezone_offset":10800,"current":{"dt":1609623860,"sunrise":1609650620,"sunset":1609684530,"temp":2.26,"feels_like":-0.99,"pressure":1026,"humidity":72,"dew_point":-2,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.37,"wind_deg":72,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}]},"minutely":[{"dt":1609623900,"precipitation":0},{"dt":1609623960,"precipitation":0},{"dt":1609624020,"precipitation":0},{"dt":1609624080,"precipitation":0},{"dt":1609624140,"precipitation":0},{"dt":1609624200,"precipitation":0},{"dt":1609624260,"precipitation":0},{"dt":1609624320,"precipitation":0},{"dt":1609624380,"precipitation":0},{"dt":1609624440,"precipitation":0},{"dt":1609624500,"precipitation":0},{"dt":1609624560,"precipitation":0},{"dt":1609624620,"precipitation":0},{"dt":1609624680,"precipitation":0},{"dt":1609624740,"precipitation":0},{"dt":1609624800,"precipitation":0},{"dt":1609624860,"precipitation":0},{"dt":1609624920,"precipitation":0},{"dt":1609624980,"precipitation":0},{"dt":1609625040,"precipitation":0},{"dt":1609625100,"precipitation":0},{"dt":1609625160,"precipitation":0},{"dt":1609625220,"precipitation":0},{"dt":1609625280,"precipitation":0},{"dt":1609625340,"precipitation":0},{"dt":1609625400,"precipitation":0},{"dt":1609625460,"precipitation":0},{"dt":1609625520,"precipitation":0},{"dt":1609625580,"precipitation":0},{"dt":1609625640,"precipitation":0},{"dt":1609625700,"precipitation":0},{"dt":1609625760,"precipitation":0},{"dt":1609625820,"precipitation":0},{"dt":1609625880,"precipitation":0},{"dt":1609625940,"precipitation":0},{"dt":1609626000,"precipitation":0},{"dt":1609626060,"precipitation":0},{"dt":1609626120,"precipitation":0},{"dt":1609626180,"precipitation":0},{"dt":1609626240,"precipitation":0},{"dt":1609626300,"precipitation":0},{"dt":1609626360,"precipitation":0},{"dt":1609626420,"precipitation":0},{"dt":1609626480,"precipitation":0},{"dt":1609626540,"precipitation":0},{"dt":1609626600,"precipitation":0},{"dt":1609626660,"precipitation":0},{"dt":1609626720,"precipitation":0},{"dt":1609626780,"precipitation":0},{"dt":1609626840,"precipitation":0},{"dt":1609626900,"precipitation":0},{"dt":1609626960,"precipitation":0},{"dt":1609627020,"precipitation":0},{"dt":1609627080,"precipitation":0},{"dt":1609627140,"precipitation":0},{"dt":1609627200,"precipitation":0},{"dt":1609627260,"precipitation":0},{"dt":1609627320,"precipitation":0},{"dt":1609627380,"precipitation":0},{"dt":1609627440,"precipitation":0},{"dt":1609627500,"precipitation":0}],"hourly":[{"dt":1609621200,"temp":2.26,"feels_like":-0.99,"pressure":1026,"humidity":72,"dew_point":-2,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.37,"wind_deg":72,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609624800,"temp":3.06,"feels_like":-0.06,"pressure":1026,"humidity":73,"dew_point":-1.15,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.36,"wind_deg":73,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609628400,"temp":3.55,"feels_like":0.24,"pressure":1026,"humidity":74,"dew_point":-0.57,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.76,"wind_deg":69,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609632000,"temp":3.7,"feels_like":0.26,"pressure":1026,"humidity":74,"dew_point":-0.44,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.98,"wind_deg":68,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609635600,"temp":3.3,"feels_like":-0.02,"pressure":1026,"humidity":77,"dew_point":-0.3,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.83,"wind_deg":66,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609639200,"temp":3.08,"feels_like":-0.29,"pressure":1026,"humidity":78,"dew_point":-1.55,"uvi":0,"clouds":0,"visibility":10000,"wind_speed":1.9,"wind_deg":68,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609642800,"temp":2.68,"feels_like":-0.58,"pressure":1026,"humidity":80,"dew_point":-1.74,"uvi":0,"clouds":2,"visibility":10000,"wind_speed":1.73,"wind_deg":61,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609646400,"temp":2.91,"feels_like":-0.69,"pressure":1026,"humidity":78,"dew_point":-1.77,"uvi":0,"clouds":1,"visibility":10000,"wind_speed":2.19,"wind_deg":63,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609650000,"temp":2.31,"feels_like":-0.83,"pressure":1026,"humidity":82,"dew_point":-1.84,"uvi":0,"clouds":15,"visibility":10000,"wind_speed":1.56,"wind_deg":70,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609653600,"temp":3.76,"feels_like":0.53,"pressure":1026,"humidity":74,"dew_point":-1.75,"uvi":0.2,"clouds":29,"visibility":10000,"wind_speed":1.69,"wind_deg":70,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"pop":0},{"dt":1609657200,"temp":6.01,"feels_like":2.76,"pressure":1026,"humidity":63,"dew_point":-1.27,"uvi":0.55,"clouds":100,"visibility":10000,"wind_speed":1.7,"wind_deg":67,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609660800,"temp":7.55,"feels_like":4.39,"pressure":1026,"humidity":57,"dew_point":-1.22,"uvi":1.1,"clouds":100,"visibility":10000,"wind_speed":1.59,"wind_deg":74,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609664400,"temp":8.65,"feels_like":5.61,"pressure":1025,"humidity":53,"dew_point":-1,"uvi":1.56,"clouds":100,"visibility":10000,"wind_speed":1.42,"wind_deg":79,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609668000,"temp":9.47,"feels_like":6.36,"pressure":1024,"humidity":50,"dew_point":-0.8,"uvi":1.68,"clouds":100,"visibility":10000,"wind_speed":1.52,"wind_deg":86,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609671600,"temp":9.96,"feels_like":6.64,"pressure":1023,"humidity":49,"dew_point":-0.72,"uvi":1.41,"clouds":100,"visibility":10000,"wind_speed":1.86,"wind_deg":84,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609675200,"temp":10.16,"feels_like":7.02,"pressure":1022,"humidity":48,"dew_point":-0.76,"uvi":0.9,"clouds":100,"visibility":10000,"wind_speed":1.58,"wind_deg":79,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609678800,"temp":9.96,"feels_like":7.12,"pressure":1022,"humidity":49,"dew_point":-0.6,"uvi":0.39,"clouds":100,"visibility":10000,"wind_speed":1.17,"wind_deg":76,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609682400,"temp":8.25,"feels_like":5.56,"pressure":1023,"humidity":56,"dew_point":0.04,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":1,"wind_deg":81,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609686000,"temp":6.37,"feels_like":3.53,"pressure":1023,"humidity":63,"dew_point":-0.42,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":1.19,"wind_deg":85,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609689600,"temp":6.08,"feels_like":3.17,"pressure":1023,"humidity":64,"dew_point":-0.51,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":1.28,"wind_deg":80,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609693200,"temp":5.66,"feels_like":2.84,"pressure":1024,"humidity":66,"dew_point":-0.57,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":1.15,"wind_deg":89,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609696800,"temp":5.35,"feels_like":2.6,"pressure":1024,"humidity":67,"dew_point":-0.7,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":1.03,"wind_deg":88,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609700400,"temp":5.17,"feels_like":2.55,"pressure":1024,"humidity":68,"dew_point":-0.81,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":0.86,"wind_deg":90,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609704000,"temp":4.66,"feels_like":2.12,"pressure":1024,"humidity":70,"dew_point":-1.03,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":0.72,"wind_deg":88,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609707600,"temp":4.11,"feels_like":1.43,"pressure":1023,"humidity":72,"dew_point":-1.31,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":0.89,"wind_deg":87,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609711200,"temp":3.65,"feels_like":1.2,"pressure":1023,"humidity":75,"dew_point":-1.44,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":0.59,"wind_deg":110,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609714800,"temp":3.17,"feels_like":1,"pressure":1023,"humidity":77,"dew_point":-1.44,"uvi":0,"clouds":100,"visibility":10000,"wind_speed":0.17,"wind_deg":168,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609718400,"temp":2.75,"feels_like":0.51,"pressure":1023,"humidity":80,"dew_point":-1.31,"uvi":0,"clouds":98,"visibility":10000,"wind_speed":0.29,"wind_deg":36,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"pop":0},{"dt":1609722000,"temp":2.38,"feels_like":-0.1,"pressure":1023,"humidity":82,"dew_point":-1.33,"uvi":0,"clouds":37,"visibility":10000,"wind_speed":0.63,"wind_deg":81,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"pop":0},{"dt":1609725600,"temp":2.1,"feels_like":-0.49,"pressure":1023,"humidity":83,"dew_point":-1.59,"uvi":0,"clouds":19,"visibility":10000,"wind_speed":0.77,"wind_deg":88,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609729200,"temp":1.86,"feels_like":-0.54,"pressure":1023,"humidity":84,"dew_point":-1.77,"uvi":0,"clouds":12,"visibility":10000,"wind_speed":0.48,"wind_deg":93,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609732800,"temp":1.65,"feels_like":-0.77,"pressure":1023,"humidity":85,"dew_point":-1.93,"uvi":0,"clouds":9,"visibility":10000,"wind_speed":0.5,"wind_deg":108,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609736400,"temp":1.62,"feels_like":-0.93,"pressure":1023,"humidity":86,"dew_point":-1.92,"uvi":0,"clouds":8,"visibility":10000,"wind_speed":0.71,"wind_deg":125,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"pop":0},{"dt":1609740000,"temp":3.22,"feels_like":0.54,"pressure":1023,"humidity":77,"dew_point":-1.43,"uvi":0.2,"clouds":6,"visibility":10000,"wind_speed":0.91,"wind_deg":114,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"pop":0},{"dt":1609743600,"temp":6.78,"feels_like":4.06,"pressure":1023,"humidity":60,"dew_point":-1.04,"uvi":0.59,"clouds":0,"visibility":10000,"wind_speed":0.96,"wind_deg":115,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"pop":0},{"dt":1609747200,"temp":8.01,"feels_like":5.38,"pressure":1022,"humidity":56,"dew_point":-0.88,"uvi":1.18,"clouds":0,"visibility":10000,"wind_speed":0.87,"wind_deg":131,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"pop":0},{"dt":1609750800,"temp":8.83,"feels_like":6.08,"pressure":1021,"humidity":53,"dew_point":-0.47,"uvi":1.66,"clouds":29,"visibility":10000,"wind_speed":1.05,"wind_deg":124,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"pop":0},{"dt":1609754400,"temp":9.46,"feels_like":6.49,"pressure":1020,"humidity":51,"dew_point":0.02,"uvi":1.74,"clouds":47,"visibility":10000,"wind_speed":1.37,"wind_deg":145,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"pop":0},{"dt":1609758000,"temp":9.94,"feels_like":6.92,"pressure":1019,"humidity":52,"dew_point":0.55,"uvi":1.46,"clouds":58,"visibility":10000,"wind_speed":1.59,"wind_deg":155,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"pop":0},{"dt":1609761600,"temp":10.25,"feels_like":7.2,"pressure":1018,"humidity":52,"dew_point":0.95,"uvi":0.93,"clouds":65,"visibility":10000,"wind_speed":1.7,"wind_deg":156,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"pop":0},{"dt":1609765200,"temp":10.11,"feels_like":6.92,"pressure":1018,"humidity":54,"dew_point":1.3,"uvi":0.45,"clouds":98,"visibility":10000,"wind_speed":1.98,"wind_deg":155,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"pop":0},{"dt":1609768800,"temp":8.43,"feels_like":5.34,"pressure":1018,"humidity":62,"dew_point":1.79,"uvi":0,"clouds":49,"visibility":10000,"wind_speed":1.92,"wind_deg":138,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"pop":0},{"dt":1609772400,"temp":6.46,"feels_like":3.08,"pressure":1019,"humidity":70,"dew_point":1.58,"uvi":0,"clouds":32,"visibility":10000,"wind_speed":2.29,"wind_deg":116,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"pop":0},{"dt":1609776000,"temp":5.78,"feels_like":2.68,"pressure":1019,"humidity":74,"dew_point":1.65,"uvi":0,"clouds":25,"visibility":10000,"wind_speed":1.93,"wind_deg":109,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"pop":0},{"dt":1609779600,"temp":5.51,"feels_like":2.42,"pressure":1019,"humidity":76,"dew_point":1.65,"uvi":0,"clouds":20,"visibility":10000,"wind_speed":1.94,"wind_deg":102,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609783200,"temp":5.2,"feels_like":2.13,"pressure":1019,"humidity":77,"dew_point":1.66,"uvi":0,"clouds":17,"visibility":10000,"wind_speed":1.88,"wind_deg":98,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609786800,"temp":4.96,"feels_like":1.8,"pressure":1019,"humidity":77,"dew_point":1.41,"uvi":0,"clouds":16,"visibility":10000,"wind_speed":1.96,"wind_deg":98,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02n"}],"pop":0},{"dt":1609790400,"temp":4.73,"feels_like":1.54,"pressure":1019,"humidity":77,"dew_point":1.14,"uvi":0,"clouds":38,"visibility":10000,"wind_speed":1.94,"wind_deg":99,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"pop":0}],"daily":[{"dt":1609664400,"sunrise":1609650620,"sunset":1609684530,"temp":{"day":8.65,"min":2.26,"max":10.16,"night":4.66,"eve":6.37,"morn":2.68},"feels_like":{"day":5.61,"night":2.12,"eve":3.53,"morn":-0.58},"pressure":1025,"humidity":53,"dew_point":-1,"wind_speed":1.42,"wind_deg":79,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"clouds":100,"pop":0,"uvi":1.68},{"dt":1609750800,"sunrise":1609737022,"sunset":1609770983,"temp":{"day":8.83,"min":1.62,"max":10.25,"night":4.73,"eve":6.46,"morn":1.86},"feels_like":{"day":6.08,"night":1.54,"eve":3.08,"morn":-0.54},"pressure":1021,"humidity":53,"dew_point":-0.47,"wind_speed":1.05,"wind_deg":124,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"clouds":29,"pop":0,"uvi":1.74},{"dt":1609837200,"sunrise":1609823421,"sunset":1609857436,"temp":{"day":6.76,"min":3.75,"max":6.93,"night":3.88,"eve":5.25,"morn":4.19},"feels_like":{"day":4.84,"night":1.69,"eve":2.76,"morn":0.95},"pressure":1019,"humidity":70,"dew_point":1.73,"wind_speed":0.28,"wind_deg":74,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"clouds":100,"pop":0.84,"rain":3.33,"uvi":0.92},{"dt":1609923600,"sunrise":1609909818,"sunset":1609943891,"temp":{"day":7.92,"min":2.25,"max":9.68,"night":5.61,"eve":6.62,"morn":2.25},"feels_like":{"day":5.61,"night":3.19,"eve":3.93,"morn":-0.48},"pressure":1024,"humidity":75,"dew_point":3.86,"wind_speed":1.35,"wind_deg":138,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"clouds":85,"pop":0,"uvi":1.53},{"dt":1610010000,"sunrise":1609996213,"sunset":1610030348,"temp":{"day":9.52,"min":3.3,"max":11.03,"night":5.83,"eve":7.61,"morn":3.3},"feels_like":{"day":6.47,"night":2.14,"eve":3.99,"morn":0.96},"pressure":1018,"humidity":59,"dew_point":2.02,"wind_speed":1.94,"wind_deg":193,"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"clouds":73,"pop":0,"uvi":1.36},{"dt":1610096400,"sunrise":1610082606,"sunset":1610116805,"temp":{"day":8.46,"min":3.38,"max":10.97,"night":6.64,"eve":7.48,"morn":3.38},"feels_like":{"day":5.89,"night":4.27,"eve":5.51,"morn":0.69},"pressure":1020,"humidity":57,"dew_point":0.64,"wind_speed":0.93,"wind_deg":186,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"clouds":99,"pop":0,"uvi":2},{"dt":1610182800,"sunrise":1610168997,"sunset":1610203264,"temp":{"day":8.61,"min":7.2,"max":10.59,"night":9.15,"eve":10.06,"morn":7.46},"feels_like":{"day":5.94,"night":6.09,"eve":7.12,"morn":4.51},"pressure":1018,"humidity":74,"dew_point":4.26,"wind_speed":2,"wind_deg":174,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"clouds":100,"pop":0.38,"rain":0.35,"uvi":2},{"dt":1610269200,"sunrise":1610255385,"sunset":1610289724,"temp":{"day":12.17,"min":6.69,"max":14.54,"night":9.62,"eve":10.91,"morn":6.69},"feels_like":{"day":9.55,"night":7.19,"eve":8.57,"morn":3.86},"pressure":1020,"humidity":59,"dew_point":4.61,"wind_speed":1.96,"wind_deg":194,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"clouds":74,"pop":0.51,"rain":0.99,"uvi":2}]}
ant this is my weather model
struct Weather: Codable {
let lat, lon: Double
let timezone: String?
let timezoneOffset: Int?
let current: Current?
let minutely: [Minutely]?
let hourly: [Current]?
let daily: [Daily]?
enum CodingKeys: String, CodingKey {
case lat, lon, timezone
case timezoneOffset
case current, minutely, hourly, daily
}}
struct Current: Codable {
let dt, sunrise, sunset: Int?
let temp, feelsLike: Double?
let pressure, humidity: Int?
let dewPoint, uvi: Double?
let clouds, visibility: Int?
let windSpeed: Double?
let windDeg: Int?
let weather: [WeatherElement]?
let pop: Double?
let rain: Rain?
enum CodingKeys: String, CodingKey {
case dt, sunrise, sunset, temp
case feelsLike
case pressure, humidity
case dewPoint
case uvi, clouds, visibility
case windSpeed
case windDeg
case weather, pop, rain
}}
struct Rain: Codable {
let the1H: Double?
enum CodingKeys: String, CodingKey {
case the1H
}}
struct WeatherElement: Codable {
let id: Int?
let main, weatherDescription, icon: String?
enum CodingKeys: String, CodingKey {
case id, main
case weatherDescription
case icon
}}
struct Daily: Codable {
let dt, sunrise, sunset: Int?
let temp: Temp?
let feelsLike: FeelsLike?
let pressure, humidity: Int?
let dewPoint, windSpeed: Double?
let windDeg: Int?
let weather: [WeatherElement]?
let clouds: Int?
let pop, uvi, rain: Double?
enum CodingKeys: String, CodingKey {
case dt, sunrise, sunset, temp
case feelsLike
case pressure, humidity
case dewPoint
case windSpeed
case windDeg
case weather, clouds, pop, uvi, rain
}}
struct FeelsLike: Codable {
let day, night, eve, morn: Double?}
struct Temp: Codable {
let day, min, max, night: Double?
let eve, morn: Double?}
struct Minutely: Codable {
let dt, precipitation: Double?}
its my first time here. Sorry for my mistakes.
The problem is the names of the variables, for example:
timezone_offset should be exactly like it is, not timezoneOffset
you can update the enum CodingKeys to avoid bad naming practices.
enum CodingKeys: String, CodingKey {
case lat, lon, timezone
case timezoneOffset = "timezone_offset"
case current, minutely, hourly, daily
}}