// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. package person import "fmt" import "encoding/json" type Person struct { // Email corresponds to the JSON schema field "email". Email []PersonEmailElem `json:"email"` // Name corresponds to the JSON schema field "name". Name PersonName `json:"name"` } type PersonEmailElem struct { // Address corresponds to the JSON schema field "address". Address *string `json:"address,omitempty"` // Kind corresponds to the JSON schema field "kind". Kind *string `json:"kind,omitempty"` } type PersonName struct { // Family corresponds to the JSON schema field "family". Family *string `json:"family,omitempty"` // Personal corresponds to the JSON schema field "personal". Personal *string `json:"personal,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. func (j *Person) UnmarshalJSON(b []byte) error { var raw map[string]interface{} if err := json.Unmarshal(b, &raw); err != nil { return err } if v, ok := raw["email"]; !ok || v == nil { return fmt.Errorf("field email: required") } if v, ok := raw["name"]; !ok || v == nil { return fmt.Errorf("field name: required") } type Plain Person var plain Plain if err := json.Unmarshal(b, &plain); err != nil { return err } *j = Person(plain) return nil } func (name PersonName) String() string { return fmt.Sprintf("Name{Personal: %s, Family: %s}", *name.Personal, *name.Family) } func (email PersonEmailElem) String() string { return fmt.Sprintf("Email{Address: %s, Kind: %s}", *email.Address, *email.Kind) }