diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2016-11-22 22:41:59 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2016-11-22 22:41:59 -0500 |
| commit | fbb328b6c33470f8aec74fcb5e6e7d0388067c1e (patch) | |
| tree | 6e33586135c23841e6760effc3b54835e7c2bb4c /modern.go | |
| parent | 47ae04e16e467d4fc2114c89e24efdb14223c8f4 (diff) | |
| download | lastfm-api-fbb328b6c33470f8aec74fcb5e6e7d0388067c1e.tar.gz | |
better marshalling
Diffstat (limited to 'modern.go')
| -rw-r--r-- | modern.go | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -25,18 +25,31 @@ type Token struct { string } +type Attrs struct { + Accepted int `xml:"accepted,attr" json:"accepted"` + Ignored int `xml:"ignored,attr" json:"ignored"` +} + type Scrobbles struct { - XMLName xml.Name `xml:"scrobbles"` - Scrobbles []Scrobble + XMLName xml.Name `xml:"scrobbles" json:scrobbles"` + Scrobbles []Scrobble `xml:"scrobble" json:scrobble` + Attrs `json:"@attr"` } -type Scrobble struct { - Track Track `xml:"track"` +type Correctable struct { + Corrected int `xml:"corrected,attr" json:"corrected"` + Name string `xml:",chardata" json:"#text"` +} + +func NewCorrectable(name string) Correctable { + return Correctable{ + Corrected: 0, + Name: name, + } } -type Track struct { - Corrected int `xml:"corrected,attr"` - Name string `xml:",chardata"` +func (field *Correctable) String() string { + return field.Name } func (n Name) getName() string { |
