MCPcopy
hub / github.com/golang/protobuf / MarshalToString

Method MarshalToString

jsonpb/encode.go:78–84  ·  view source on GitHub ↗

MarshalToString serializes a protobuf message as JSON in string form.

(m proto.Message)

Source from the content-addressed store, hash-verified

76
77// MarshalToString serializes a protobuf message as JSON in string form.
78func (jm *Marshaler) MarshalToString(m proto.Message) (string, error) {
79 b, err := jm.marshal(m)
80 if err != nil {
81 return "", err
82 }
83 return string(b), nil
84}
85
86func (jm *Marshaler) marshal(m proto.Message) ([]byte, error) {
87 v := reflect.ValueOf(m)

Callers 8

TestMarshalingNilFunction · 0.95
TestMarshalingFunction · 0.80
TestMarshalIllegalTimeFunction · 0.80

Implementers 6

TextMarshalerproto/text_encode.go
Bufferproto/buffer.go
InternalMessageInfoproto/deprecated.go
fakeMarshalerproto/proto_test.go
nonptrMessageproto/proto_test.go
Marshalerjsonpb/encode.go

Calls 1

marshalMethod · 0.95

Tested by 8

TestMarshalingNilFunction · 0.76
TestMarshalingFunction · 0.64
TestMarshalIllegalTimeFunction · 0.64