code: func (d *duration) UnmarshalJSON(data []byte) error {
  	if len(data) == 0 {
  		*d = 0
  		return nil
  	}
  	text := string(data)
  	t, err := time.ParseDuration(text)
  	if err == nil {
  		*d = duration(t)
  		return nil
  	}
  	i, err := strconv.ParseInt(text, 10, 64)
  	if err == nil {
  		*d = duration(time.Duration(i) * time.Second)
  		return nil
  	}
  	// This hack is to get around strconv.ParseFloat
  	// not handling e-notation for integers.
  	f, err := strconv.ParseFloat(text, 64)
  	*d = duration(time.Duration(f) * time.Second)
  	return err
  }
docs: // UnmarshalJSON unmarshals a duration according to the following scheme:
  //  * If the element is absent the duration is zero.
  //  * If the element is parsable as a time.Duration, the parsed value is kept.
  //  * If the element is parsable as a number, that number of seconds is kept.