// EncodeJSON encodes a transaction into a JSON data dump.
229
func (tx *Transaction) EncodeJSON() (string, error) {
	data, err := json.Marshal(tx.tx)
	return string(data), err
}
1172284
func (b *Block) EncodeJSON() (string, error) {
	data, err := json.Marshal(b.block)
	return string(data), err
}
874845
func (c *Codec) Encode(chk *Chunk) []byte {
	buffer := make([]byte, 0, chk.MemoryUsage())
	for _, col := range chk.columns {
		buffer = c.encodeColumn(buffer, col)
	}
	return buffer
}
425650
func (v BytesValue) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}

	return raw.encodeBytes(w, []byte(v))
}
775469
func EncodeJSONResponse(
	ctx context.Context,
	pub *amqp.Publishing,
	response interface{},
) error {
	b, err := json.Marshal(response)
	if err != nil {
		return err
	}
	pub.Body = b
	return nil
}
928499
func (enc *Encoder) Encode(m *Message) (err error) {

	_, err = enc.Write(m.Bytes())

	return
}
782057
func Encode(e Encoder, obj Object) ([]byte, error) {
	return e.Encode(obj)
}
1071875
func (e *ExchangeMessage) WriteJSON(v interface{}) error {
	x, err := json.Marshal(v)
	if err != nil {
		return err
	}
	e.body = x
	return nil
}
684601
func FromJSON(jsonBytes []byte) ([]byte, error) {
	var j EncodedCaddyfile
	var result string

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

	for sbPos, sb := range j {
		if sbPos > 0 {
			result += "\n\n"
		}
		for i, key := range sb.Keys {
			if i > 0 {
				result += ", "
			}
			//result += standardizeScheme(key)
			result += key
		}
		result += jsonToText(sb.Body, 1)
	}

	return []byte(result), nil
}
495507
func (codec *StringCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(string); ok {
		return out.WriteString(msg)
	}

	return fmt.Errorf("not string: %+v", data)
}
360382
func (yd *YAMLDecoder) Encode(data []*FileDataEntry) ([]byte, error) {
	// Convert to json-specific structure
	var yamlFileEntries []yamlFileEntry
	for _, dataEntry := range data {
		yamlFileEntries = append(yamlFileEntries, yamlFileEntry{
			Key:   dataEntry.Key,
			Value: dataEntry.Value,
		})
	}
	// Encode to type specific structure
	yamlFile := &yamlFile{Data: yamlFileEntries}
	return yaml.Marshal(yamlFile)
}
1307837
func EncodeJSONResponse(_ context.Context, reply string, nc *nats.Conn, response interface{}) error {
	b, err := json.Marshal(response)
	if err != nil {
		return err
	}

	return nc.Publish(reply, b)
}
621730
func (tx *Transaction) UnmarshalJSON(data []byte) error {
	type jsontx struct {
		BlockHeight    uint32          `json:"blockheight,omitempty"`
		FeesPaid       uint64          `json:"feespaid,omitempty"`
		FeesRequired   uint64          `json:"feesrequired,omitempty"`
		IsSigned       bool            `json:"signed"`
		Name           string          `json:"name,omitempty"`
		Timestamp      int64           `json:"timestamp"`
		TotalECOutputs uint64          `json:"totalecoutputs"`
		TotalInputs    uint64          `json:"totalinputs"`
		TotalOutputs   uint64          `json:"totaloutputs"`
		Inputs         []*TransAddress `json:"inputs"`
		Outputs        []*TransAddress `json:"outputs"`
		ECOutputs      []*TransAddress `json:"ecoutputs"`
		TxID           string          `json:"txid,omitempty"`
	}
	tmp := new(jsontx)

	if err := json.Unmarshal(data, tmp); err != nil {
		return err
	}

	tx.BlockHeight = tmp.BlockHeight
	tx.FeesPaid = tmp.FeesPaid
	tx.FeesRequired = tmp.FeesRequired
	tx.IsSigned = tmp.IsSigned
	tx.Name = tmp.Name
	tx.Timestamp = time.Unix(tmp.Timestamp, 0)
	tx.TotalECOutputs = tmp.TotalECOutputs
	tx.TotalInputs = tmp.TotalInputs
	tx.TotalOutputs = tmp.TotalOutputs
	tx.Inputs = tmp.Inputs
	tx.Outputs = tmp.Outputs
	tx.ECOutputs = tmp.ECOutputs
	tx.TxID = tmp.TxID

	return nil
}
112523
func (enc *Encoder) EncodeObject(v MarshalerJSONObject) error {
	if enc.isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	_, err := enc.encodeObject(v)
	if err != nil {
		enc.err = err
		return err
	}
	_, err = enc.Write()
	if err != nil {
		enc.err = err
		return err
	}
	return nil
}
1169149
func (jd *JSONDecoder) Encode(data []*FileDataEntry) ([]byte, error) {
	// Convert to json-specific structure
	var jsonFileEntries []jsonFileEntry
	for _, dataEntry := range data {
		jsonFileEntries = append(jsonFileEntries, jsonFileEntry{
			Key:   dataEntry.Key,
			Value: dataEntry.Value,
		})
	}
	// Encode to type specific structure
	jsonFile := &jsonFile{Data: jsonFileEntries}
	return json.Marshal(jsonFile)
}
805945
func writeJSON(buf *bytes.Buffer, v interface{}, keyName string) error {
	if enc, err := json.Marshal(v); err != nil {
		return errors.Wrapf(err, `failed to encode '%s'`, keyName)
	} else {
		buf.Write(enc)
	}
	return nil
}
235279
func JSONEncode(value interface{}) ([]byte, uint32, error) {
	var bytes []byte
	flags := gocbcore.EncodeCommonFlags(gocbcore.JsonType, gocbcore.NoCompression)
	var err error

	switch typeValue := value.(type) {
	case []byte:
		bytes = typeValue
	case *[]byte:
		bytes = *typeValue
	case *interface{}:
		return JSONEncode(*typeValue)
	default:
		bytes, err = json.Marshal(value)
		if err != nil {
			return nil, 0, err
		}
	}

	// No compression supported currently

	return bytes, flags, nil
}