zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.41k stars 295 forks source link

[bug] Spotify API returns float numbers instead of int numbers, results in errors when using our Go structs when unmarshalling JSON #250

Closed SLAzurin closed 9 months ago

SLAzurin commented 9 months ago

I use the client.GetTrack to get a Track struct, but it has been erroring the past 1-2 days. The Spotify APIs has recently changed to use float numbers instead of int for JSON objects.

Go error value:

json: cannot unmarshal number 2.0 into Go struct field FullTrack.track_number of type int

Temporary workaround personal solution: https://github.com/SLAzurin/spotify-go/commit/a386b802b7f24be842aaf1460109874de6aedd0f

I am not that experienced with this codebase but that seemed to make it work well enough for my use case. This commit does not cover all the possible JSON Number fields.

Please let me know if there are any more details you need. 🙂

SLAzurin commented 9 months ago

I will close this issue since it is related to https://github.com/zmb3/spotify/issues/243