Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid data type of cod and message #71

Open
sebastian-garn opened this issue Sep 13, 2018 · 1 comment
Open

Invalid data type of cod and message #71

sebastian-garn opened this issue Sep 13, 2018 · 1 comment

Comments

@sebastian-garn
Copy link

sebastian-garn commented Sep 13, 2018

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:

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:

  1. You can either define COD as string and Message as type float64
  2. 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

@apprell
Copy link

apprell commented Oct 19, 2020

Hi, the same problem, why not do it like in forecast5.go by commenting out these lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants