code: func (c *CredentialValue) UnmarshalJSON(b []byte) error {
  	impl := credentialImpl{}
  
  	s, err := strconv.Unquote(string(b))
  	if err != nil {
  		return err
  	}
  
  	if len(s) == 0 {
  		v := reflect.ValueOf(c).Elem()
  		v.Set(reflect.Zero(v.Type()))
  		return nil
  	}
  
  	err = json.Unmarshal([]byte(s), &impl)
  	if err != nil {
  		return err
  	}
  
  	switch impl.Body.Type {
  	case "undefined":
  		c.cvtype = unsetCV
  	case "undecrypted":
  		c.cvtype = undecryptedCV
  	case "string":
  		c.cvtype = stringCV
  		var v string
  		err := json.Unmarshal(impl.Body.Value, &v)
  		if err != nil {
  			return errMistmatchedType
  		}
  
  		c.raw = v
  		c.value = v
  	case "number":
  		c.cvtype = stringCV
  		var v json.Number
  		err := json.Unmarshal(impl.Body.Value, &v)
  		if err != nil {
  			return errMistmatchedType
  		}
  
  		if i, err := v.Int64(); err == nil {
  			c.cvtype = intCV
  			c.raw = i
  		} else if f, err := v.Float64(); err == nil {
  			c.cvtype = floatCV
  			c.raw = f
  		}
  
  		c.value = v.String()
  	default:
  		return errors.New("Decoding type " + impl.Body.Type + " is not supported")
  	}
  	return nil
  }
docs: // UnmarshalJSON implements the json.Unmarshaler interface.