Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Parsing error #12

Closed
miton18 opened this issue Mar 20, 2019 · 3 comments
Closed

Parsing error #12

miton18 opened this issue Mar 20, 2019 · 3 comments

Comments

@miton18
Copy link
Contributor

miton18 commented Mar 20, 2019

Hi ! I'm having the issue below:

ERRO[0300] cannot scrape unifi controller metrics        error="cannot list aps: json: cannot unmarshal number 201.2856790274727 into Go struct field UAP.x of type int"

When calling

unifi.Aps(site)

https://github.com/dim13/unifi/blob/master/uap.go#L277

Unifi controller: 5.10.19

@miton18
Copy link
Contributor Author

miton18 commented Mar 20, 2019

Its like x and y are of type string if there are not set (if you don't put a device int the map)
and it's become a float when there are on the map

@dim13
Copy link
Owner

dim13 commented Mar 21, 2019

According to the error message, it should be enough just to change field type from int to float64. Can you please verify it first?

As for the case of inconsistency (sometimes string, sometimes numeric) -- there are multiple such places in unifi api.

Thus, I'm more thinking about implementing "fuzzy" types package (json.Unmarshaler interface), instead of going to naked interface{}, as you've proposed in your PR #13.

See example here: https://play.golang.org/p/gcna9Ra_Kvh

@miton18
Copy link
Contributor Author

miton18 commented Mar 21, 2019

I don't know about fuzzy type, in fact, it's a cleaner way to deal with this issue,
I just update PR #13

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

No branches or pull requests

2 participants