I am using the 16 days weather forecast but I get the error "json: cannot unmarshal number into Go value of type string".
The issue occurs because the struct is defined as:
type Forecast16WeatherData struct {
COD int `json:"cod"`
Message string `json:"message"`
City City `json:"city"`
Cnt int `json:"cnt"`
List []Forecast16WeatherList `json:"list"`
}
But the json response looks like:
{
...
"cod":"200",
"message":0.9065923,
...
}
The following solutions fix this issue:
You can either define COD as string and Message as type float64
Comment out both fields
Looking at the examples in docs of OWM the COD should be int. So your model is correct but the actually json response differs...so I would prefer solution 2 until the staff of OWM has fixed it or at least adjust the examples ;)
Btw. solution 2 was already implemented in forecast5.go
Hi,
I am using the 16 days weather forecast but I get the error "json: cannot unmarshal number into Go value of type string". The issue occurs because the struct is defined as:
But the json response looks like:
The following solutions fix this issue:
Looking at the examples in docs of OWM the COD should be int. So your model is correct but the actually json response differs...so I would prefer solution 2 until the staff of OWM has fixed it or at least adjust the examples ;)
Btw. solution 2 was already implemented in forecast5.go