Blob
- Date:
- Message:
- Use default MarshalJSON method There's no point doing so much manual work and testing just to keep fields under a "attrs" key when marshalling to JSON. When creating the object we can just: 1. Marshal the object to JSON 2. Put it all under a "attrs" key. Now it's easier to imagine the mapping of the structs to JSON, since they follow the same rules as everything else in Go.
- Actions:
- History | Blame | Raw File
1 package icinga3 // User represents a User object.4 // Note that this is different from an ApiUser.5 type User struct {6 Name string `json:"-"`7 Email string `json:"email,omitempty"`8 Groups []string `json:"groups,omitempty"`9 }11 func (u User) name() string {12 return u.Name13 }15 func (u User) path() string {16 return "/objects/users/" + u.Name17 }