zmb3 / spotify

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

Fix ExternalURL collections #6

Closed brandur closed 8 years ago

brandur commented 8 years ago

The current implementation seem to map these collections to a single struct (the ExternalURL type) containing a Key/Value which in practice doesn't unmarshal to anything. As dictated by the documentation [1], these are simple objects mapping a string to a string and that's unlikely to change during this API version, so I'd recommend using a simple map instead (for user convenience).

The ExternalURL seems to be using the special JSON annotations of json:"{key}", which I would guess are supposed to help unmarshal an object, but I couldn't find any record of them online (and as noted above, the singular nature of the resources will prevent a successful unmarshaling anyway, I think at the very least you'd want []ExternalURL).

Note that ExternalIDs have the same problem, but are not addressed in this pull.

[1] https://developer.spotify.com/web-api/get-playlist/

zmb3 commented 8 years ago

You couldn't find anything on those "special JSON annotations" because there's no such thing. I have no idea what I was thinking when I wrote that.

Thanks again for your contributions. I'll go ahead and fix the ExternalIDs after merging this.

brandur commented 8 years ago

You couldn't find anything on those "special JSON annotations" because there's no such thing. I have no idea what I was thinking when I wrote that.

Hah, okay I'm glad that I wasn't going crazy ;) Thanks!