Skip to content

Instantly share code, notes, and snippets.

@mnichols
Created January 5, 2018 18:44
Show Gist options
  • Save mnichols/d8a688ef5cb2a9330158a36d0d80e2e0 to your computer and use it in GitHub Desktop.
Save mnichols/d8a688ef5cb2a9330158a36d0d80e2e0 to your computer and use it in GitHub Desktop.
func (this *Identity) UnmarshalJSON(data []byte) error {
type Alias Identity
aux := &struct {
*Alias
UserID int `json:"user_id"`
TeamID int `json:"team_id"`
}{
Alias: (*Alias)(this),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
this.UserID = fmt.Sprint(aux.UserID)
this.TeamID = fmt.Sprint(aux.TeamID)
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment