// MarshalCommand marshals the given command.
10033
func MarshalCommand(t Type, msg proto.Message) ([]byte, error) {
	var b []byte
	var err error

	switch t {
	case Protobuf:
		b, err = proto.Marshal(msg)
	case JSON:
		var str string
		m := &jsonpb.Marshaler{
			EmitDefaults: true,
		}
		str, err = m.MarshalToString(msg)
		b = []byte(str)
	}

	return b, err
}
90283
func (t *Function) MarshalJSON() ([]byte, error) {
	repr := map[string]interface{}{
		"type": t.typeMarker(),
	}
	if len(t.args) > 0 {
		repr["args"] = t.args
	}
	if t.result != nil {
		repr["result"] = t.result
	}
	return json.Marshal(repr)
}
1269400
func Marshal(object interface{}) (data string, err error) {
	if t, err := json.Marshal(object); err != nil {
		data = ""
	} else {
		data = string(t)
	}
	return
}
1323614
func (term *Term) MarshalJSON() ([]byte, error) {
	d := map[string]interface{}{
		"type":  TypeName(term.Value),
		"value": term.Value,
	}
	return json.Marshal(d)
}
968163
func (v bulkUpdateRequestCommandOp) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson1ed00e60EncodeGithubComOlivereElastic(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}
1115025
func Marshal(v interface{}) ([]byte, error) {
	w := bytes.NewBuffer(nil)
	err := MarshalTo(w, v)
	return w.Bytes(), err
}
1016099
func Marshal(data interface{}) ([]byte, error) {
	document, err := MarshalToStruct(data, nil)
	if err != nil {
		return nil, err
	}

	return json.Marshal(document)
}
43390
func (h *Handle) MarshalJSON() ([]byte, error) {
	m := map[string]interface{}{
		"id": h.id,
	}

	b, err := h.ToByteArray()
	if err != nil {
		return nil, err
	}
	m["sequence"] = b
	return json.Marshal(m)
}
1063398
func encryptCommand() *cli.Command {
	return &cli.Command{
		Name:     EncryptCommandName,
		Usage:    EncryptCommandUsage,
		Action:   ActionWrapper(encryptAction),
		Category: "Encryption",
		Flags: []cli.Flag{
			cli.StringFlag{Name: "value"},
		},
	}
}
1345229
func (f *Formatter) Marshal(v interface{}) ([]byte, error) {
	data, err := json.Marshal(v)
	if err != nil {
		return nil, err
	}

	return f.Format(data)
}
257745
func (s *Serializer) Marshal(v interface{}) ([]byte, error) {
	pb, ok := v.(proto.Message)
	if !ok {
		return nil, constants.ErrWrongValueType
	}
	return proto.Marshal(pb)
}
247920
func (m MACCommand) MarshalBinary() ([]byte, error) {
	b := []byte{byte(m.CID)}

	if m.Payload != nil {
		p, err := m.Payload.MarshalBinary()
		if err != nil {
			return nil, err
		}
		b = append(b, p...)
	}
	return b, nil
}
3413
func (p ProtobufImpl) Marshal(msg proto.Message) ([]byte, error) {
	res, err := proto.Marshal(msg)
	return res, errors.WithStack(err)
}
861505
func (u Array) MarshalText() ([]byte, error) {
	var js [36]byte
	encodeHex(js[:], u[:])
	return js[:], nil
}
443576
func (c Commands) MarshalBinary() ([]byte, error) {
	var out []byte

	for _, cmd := range c {
		b, err := cmd.MarshalBinary()
		if err != nil {
			return nil, err
		}
		out = append(out, b...)
	}
	return out, nil
}
1103541
func (notOperation *Not) MarshalJSON() ([]byte, error) {
	return json.Marshal(&struct {
		Not  Comparison
		Next string
	}{
		Not:  notOperation.Comparison,
		Next: notOperation.Next.Name(),
	})
}
262253
func (b Compatibool) MarshalText() ([]byte, error) {
	if b {
		return []byte("1"), nil
	}
	return []byte("0"), nil
}