func (u *User) UnmarshalJSON(data []byte) error {
	doc := &struct {
		userAlias
		ID string `json:"_id"`
	}{}
	if err := json.Unmarshal(data, &doc); err != nil {
		return errors.Wrap(err, "failed to unmarshal user")
	}
	if !strings.HasPrefix(doc.ID, kivik.UserPrefix) {
		return errors.New("id must have '" + kivik.UserPrefix + "' prefix")
	}
	if doc.Name != strings.TrimPrefix(doc.ID, kivik.UserPrefix) {
		return errors.New("user name and id must match")
	}
	*u = User(doc.userAlias)
	return u.Validate()
}
// UnmarshalJSON implements the json.Unmarshaler interface for the User type.
UnmarshalJSON implements the json.Unmarshaler interface for the User type.
// UnmarshalJSON implements the json . Unmarshaler interface for the User type .
func (u *User) UnmarshalJSON(data []byte) error {
	doc := &struct {
		userAlias
		ID string `json:"_id"`
	}{}
	if err := json.Unmarshal(data, &doc); err != nil {
		return errors.Wrap(err, "failed to unmarshal user")
	}
	if !strings.HasPrefix(doc.ID, kivik.UserPrefix) {
		return errors.New("id must have '" + kivik.UserPrefix + "' prefix")
	}
	if doc.Name != strings.TrimPrefix(doc.ID, kivik.UserPrefix) {
		return errors.New("user name and id must match")
	}
	*u = User(doc.userAlias)
	return u.Validate()
}
func ( u * User ) UnmarshalJSON ( data [ ] byte ) error { doc := & struct { userAlias ID string `json:"_id"` } { } if err := json . Unmarshal ( data , & doc ) ; err != nil { return errors . Wrap ( err , " " ) } if ! strings . HasPrefix ( doc . ID , kivik . UserPrefix ) { return errors . New ( " " + kivik . UserPrefix + " " ) } if doc . Name != strings . TrimPrefix ( doc . ID , kivik . UserPrefix ) { return errors . New ( " " ) } * u = User ( doc . userAlias ) return u . Validate ( ) }
UnmarshalJSON implements the json.Unmarshaler interface for the User type.
UnmarshalJSON implements the json . Unmarshaler interface for the User type .