// fastTimeMarshalJSON avoids one of the extra allocations that
// time.MarshalJSON is making.
177352
func fastTimeMarshalJSON(t time.Time) (string, error) {
	if y := t.Year(); y < 0 || y >= 10000 {
		// RFC 3339 is clear that years are 4 digits exactly.
		// See golang.org/issue/4556#c15 for more discussion.
		return "", errors.New("time.MarshalJSON: year outside of range [0,9999]")
	}
	return t.Format(jsonFormat), nil
}
1369600
func (t *TimeSinceEpoch) UnmarshalJSON(data []byte) error {
	*t = 0
	if len(data) == 0 {
		return nil
	}
	var f float64
	if err := json.Unmarshal(data, &f); err != nil {
		return errors.New("network.TimeSinceEpoch: " + err.Error())
	}
	*t = TimeSinceEpoch(f)
	return nil
}
1364698
func (t *Time) MarshalJSON() ([]byte, error) {
	return []byte(t.Time.Format(`"` + DeisDatetimeFormat + `"`)), nil
}
1303887
func (dt *DateTime) UnmarshalJSON(b []byte) error {
	ts, err := time.Parse(dateTimeFmtTicked, string(b))
	if err != nil {
		return err
	}

	*dt = DateTime(ts)
	return nil
}
1370880
func (t *TimeRFC1123) UnmarshalJSON(data []byte) (err error) {
	t.Time, err = ParseTime(rfc1123JSON, string(data))
	if err != nil {
		return err
	}
	return nil
}
673715
func (t *AWSEpochTime) UnmarshalJSON(data []byte) error {
	var epochTime struct {
		Sec int64 `json:"AWS:EpochTime"`
	}
	err := json.Unmarshal(data, &epochTime)
	if err != nil {
		return err
	}
	t.Time = time.Unix(epochTime.Sec, 0).UTC()
	return nil
}
609770
func (jt Time) MarshalJSON() ([]byte, error) {
	return json.Marshal(jt.UTC().Format(time.RFC3339Nano))
}
863151
func (d *Duration) MarshalJSON() ([]byte, error) {
	if d == nil {
		return []byte("null"), nil
	}
	dur := time.Duration(*d)
	return []byte(`"` + dur.String() + `"`), nil
}
864548
func (d ConfigDuration) MarshalJSON() ([]byte, error) {
	return []byte(d.Duration.String()), nil
}
734330
func (d *Duration) UnmarshalJSON(b []byte) error {
	dur, err := readDuration(string(b))
	*d = Duration(dur)
	return err
}
1268155
func (d *Duration) UnmarshalJSON(buf []byte) error {
	var str string

	err := json.Unmarshal(buf, &str)
	if err != nil {
		return err
	}

	dur, err := time.ParseDuration(str)
	if err != nil {
		return err
	}

	d.Duration = dur
	return nil
}
547750
func (f *Float32) MarshalJSON() ([]byte, error) {
	if f == nil || !f.Valid {
		return []byte("null"), nil
	}

	return json.Marshal(f.Float32)
}
304827
func (r Raw) MarshalJSON() ([]byte, error) {
	if r == nil {
		return []byte("null"), nil
	}
	return r, nil
}
156231
func (series SeriesByTarget) MarshalJSONFast(b []byte) ([]byte, error) {
	b = append(b, '[')
	for _, s := range series {
		b = append(b, `{"target":`...)
		b = strconv.AppendQuoteToASCII(b, s.Target)
		if len(s.Tags) != 0 {
			b = append(b, `,"tags":{`...)
			for name, value := range s.Tags {
				b = strconv.AppendQuoteToASCII(b, name)
				b = append(b, ':')
				b = strconv.AppendQuoteToASCII(b, value)
				b = append(b, ',')
			}
			// Replace trailing comma with a closing bracket
			b[len(b)-1] = '}'
		}
		b = append(b, `,"datapoints":[`...)
		for _, p := range s.Datapoints {
			b = append(b, '[')
			if math.IsNaN(p.Val) {
				b = append(b, `null,`...)
			} else {
				b = strconv.AppendFloat(b, p.Val, 'f', -1, 64)
				b = append(b, ',')
			}
			b = strconv.AppendUint(b, uint64(p.Ts), 10)
			b = append(b, `],`...)
		}
		if len(s.Datapoints) != 0 {
			b = b[:len(b)-1] // cut last comma
		}
		b = append(b, `]},`...)
	}
	if len(series) != 0 {
		b = b[:len(b)-1] // cut last comma
	}
	b = append(b, ']')
	return b, nil
}
198038
func (u *UpdateTime) UnmarshalJSON(b []byte) error {
	s := strings.Trim(string(b), "\"")
	if s == "none" {
		*u = UpdateTime{&time.Time{}}
		return nil
	}
	t, err := time.Parse("2006-01-02T15:04:05", s)
	if err != nil {
		return err
	}
	*u = UpdateTime{&t}
	return nil
}
159090
func (d *Duration) MarshalJSON() ([]byte, error) {
	return json.Marshal(time.Duration(*d))
}
72268
func (cmp *TimestampLessThan) MarshalJSON() ([]byte, error) {
	return json.Marshal(&struct {
		Variable          string
		TimestampLessThan string
	}{
		Variable:          cmp.Variable,
		TimestampLessThan: cmp.Value.Format(time.RFC3339),
	})
}