// MarshalJSON encodes the web3 RPC transaction format.
421727
func (tx *Transaction) MarshalJSON() ([]byte, error) {
	hash := tx.Hash()
	data := tx.data
	data.Hash = &hash
	return data.MarshalJSON()
}
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))
}
1051093
func (u *Uint64) MarshalJSON() ([]byte, error) {
	if u == nil || !u.Valid {
		return []byte("null"), nil
	}

	return json.Marshal(u.Uint64)
}
1197823
func (dt *DateTimeRFC2616) MarshalJSON() ([]byte, error) {
	return []byte(time.Time(*dt).Format(dateTimeRFC2616FmtTicked)), nil
}
76774
func (v CBGithub) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonB0500db0EncodeGithubComFrancoispqtGojayBenchmarks4(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
238971
func (v DeliveryStatus) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonCce3d1beEncodeGithubComMailgunMailgunGoEvents7(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
529737
func (ua *Uint64Array) MarshalJSON() ([]byte, error) {
	if ua == nil || !ua.Valid {
		return []byte("null"), nil
	}
	return json.Marshal(ua.Uint64Array)
}
8958
func (v Storage) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonCce3d1beEncodeGithubComMailgunMailgunGoEvents(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
486285
func (v Stored) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson692db02bEncodeGithubComMailgunMailgunGoEvents1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
1013565
func (t JSONTime) MarshalJSON() ([]byte, error) {
	ts := t.Time().UnixNano() / 1000
	return []byte(strconv.FormatInt(ts, 10)), nil
}
215946
func (code AggregateOpcode) MarshalJSON() ([]byte, error) {
	return ([]byte)(fmt.Sprintf("\"%s\"", code.String())), nil
}
137633
func (t ts) MarshalJSON() ([]byte, error) {
	stringTime := t.Format(time.ANSIC)
	return json.Marshal(stringTime)
}
966249
func (p *payload) MarshalJSON() ([]byte, error) {
	b, err := json.Marshal(p.v)
	if err != nil {
		return nil, err
	}
	return jose.EncodeEscape(b), nil
}
1343879
func (re Unknown) MarshalJSON() ([]byte, error) {
	if re.RawJSON == nil {
		return []byte("null"), nil
	}
	return re.RawJSON, nil
}
792590
func (r replicationFactor) MarshalJSON() ([]byte, error) {
	var replicationFactor interface{}

	if int(r) == ReplicationFactorSatellite {
		replicationFactor = replicationFactorSatelliteString
	} else {
		replicationFactor = int(r)
	}

	return json.Marshal(replicationFactor)
}
865624
func (v Generic) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson692db02bEncodeGithubComMailgunMailgunGoEvents11(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
745485
func (s *PaymentSource) MarshalJSON() ([]byte, error) {
	var target interface{}

	switch s.Type {
	case PaymentSourceTypeBitcoinReceiver:
		target = struct {
			*BitcoinReceiver
			Type PaymentSourceType `json:"object"`
		}{
			BitcoinReceiver: s.BitcoinReceiver,
			Type:            s.Type,
		}
	case PaymentSourceTypeCard:
		var customerID *string
		if s.Card.Customer != nil {
			customerID = &s.Card.Customer.ID
		}

		target = struct {
			*Card
			Customer *string           `json:"customer"`
			Type     PaymentSourceType `json:"object"`
		}{
			Card:     s.Card,
			Customer: customerID,
			Type:     s.Type,
		}
	case PaymentSourceTypeAccount:
		target = struct {
			ID   string            `json:"id"`
			Type PaymentSourceType `json:"object"`
		}{
			ID:   s.ID,
			Type: s.Type,
		}
	case PaymentSourceTypeBankAccount:
		var customerID *string
		if s.BankAccount.Customer != nil {
			customerID = &s.BankAccount.Customer.ID
		}

		target = struct {
			*BankAccount
			Customer *string           `json:"customer"`
			Type     PaymentSourceType `json:"object"`
		}{
			BankAccount: s.BankAccount,
			Customer:    customerID,
			Type:        s.Type,
		}
	case "":
		target = s.ID
	}

	return json.Marshal(target)
}