// MarshalJSON allows to convert back golang values to original payload values.
358808
func (t *Torrent) MarshalJSON() (data []byte, err error) {
	// Shadow real type for regular unmarshalling
	type RawTorrent Torrent
	tmp := &struct {
		ActivityDate   *int64  `json:"activityDate"`
		AddedDate      *int64  `json:"addedDate"`
		DateCreated    *int64  `json:"dateCreated"`
		DoneDate       *int64  `json:"doneDate"`
		SecondsSeeding *int64  `json:"secondsSeeding"`
		StartDate      *int64  `json:"startDate"`
		Wanted         []int64 `json:"wanted"` // boolean in number form
		*RawTorrent
	}{
		RawTorrent: (*RawTorrent)(t),
	}
	// Timestamps & Duration
	if t.ActivityDate != nil {
		ad := t.ActivityDate.Unix()
		tmp.ActivityDate = &ad
	}
	if t.AddedDate != nil {
		ad := t.AddedDate.Unix()
		tmp.AddedDate = &ad
	}
	if t.DateCreated != nil {
		dc := t.DateCreated.Unix()
		tmp.DateCreated = &dc
	}
	if t.DoneDate != nil {
		dd := t.DoneDate.Unix()
		tmp.DoneDate = &dd
	}
	if t.SecondsSeeding != nil {
		ss := int64(*t.SecondsSeeding / time.Second)
		tmp.SecondsSeeding = &ss
	}
	if t.StartDate != nil {
		st := t.StartDate.Unix()
		tmp.StartDate = &st
	}
	// Boolean as number
	if t.Wanted != nil {
		tmp.Wanted = make([]int64, len(t.Wanted))
		for index, value := range t.Wanted {
			if value {
				tmp.Wanted[index] = 1
			}
		}
	}
	// Marshall original values within the tmp payload
	return json.Marshal(&tmp)
}
951072
func MarshalJSON(errobj error) ([]byte, error) {
	errjson, err := newJSON(1, errobj)
	if errjson == nil || err != nil {
		return []byte(""), err
	}
	return json.Marshal(errjson)
}
977458
func (obj *object) MarshalJSON() ([]byte, error) {
	sl := make([][2]*Term, obj.Len())
	for i := range obj.keys {
		k := obj.keys[i]
		sl[i] = Item(k, obj.get(k).value)
	}
	return json.Marshal(sl)
}
529737
func (ua *Uint64Array) MarshalJSON() ([]byte, error) {
	if ua == nil || !ua.Valid {
		return []byte("null"), nil
	}
	return json.Marshal(ua.Uint64Array)
}
39026
func (i *Int32) MarshalJSON() ([]byte, error) {
	if i == nil || !i.Valid {
		return []byte("null"), nil
	}

	return json.Marshal(i.Int32)
}
548109
func (b Buffer) MarshalJSON() ([]byte, error) {
	v, err := b.Base64Encode()
	if err != nil {
		return nil, errors.Wrap(err, "failed to encode to base64")
	}
	return json.Marshal(string(v))
}
850532
func (v Complained) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson692db02bEncodeGithubComMailgunMailgunGoEvents15(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
425078
func (r *Response) MarshalJSON() ([]byte, error) {
	return []byte(r.res), r.err
}
1197823
func (dt *DateTimeRFC2616) MarshalJSON() ([]byte, error) {
	return []byte(time.Time(*dt).Format(dateTimeRFC2616FmtTicked)), nil
}
865624
func (v Generic) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson692db02bEncodeGithubComMailgunMailgunGoEvents11(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
1141499
func (v SmallPayload) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson890029d8EncodeGithubComFrancoispqtGojayBenchmarks(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
161807
func (s Sample) MarshalJSON() ([]byte, error) {
	v := struct {
		Metric Metric     `json:"metric"`
		Value  SamplePair `json:"value"`
	}{
		Metric: s.Metric,
		Value: SamplePair{
			Timestamp: s.Timestamp,
			Value:     s.Value,
		},
	}

	return json.Marshal(&v)
}
876123
func (u UTCTime) MarshalJSON() ([]byte, error) {
	return []byte(fmt.Sprintf("\"%s\"", time.Time(u).UTC().Format(time.RFC3339Nano))), nil
}
1343727
func (v Value) MarshalJSON() ([]byte, error) {
	switch v.t {
	case reflect.String:
		return json.Marshal(v.s)
	case reflect.Int:
		return json.Marshal(v.i)
	case reflect.Bool:
		return json.Marshal(v.b)
	}

	return nil, fmt.Errorf("unknown value kind %v", v.t)
}
281339
func (results Results) MarshalJSON() ([]byte, error) {
	for _, result := range results {
		if result.ResultID() == "" {
			result.SetResultID(fmt.Sprintf("%d", &result))
		}

		if err := inferIQR(result); err != nil {
			return nil, err
		}
	}

	return json.Marshal([]Result(results))
}
349131
func (es Errors) MarshalJSON() ([]byte, error) {
	errs := map[string]interface{}{}
	for key, err := range es {
		if ms, ok := err.(json.Marshaler); ok {
			errs[key] = ms
		} else {
			errs[key] = err.Error()
		}
	}
	return json.Marshal(errs)
}
788198
func (bv *Value) MarshalJSON() ([]byte, error) {
	return []byte("\"" + base64.RawURLEncoding.EncodeToString(*bv) + "\""), nil
}