Created
January 5, 2018 18:44
-
-
Save mnichols/d8a688ef5cb2a9330158a36d0d80e2e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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