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

Method Marshal

jsonpb/encode.go:67–75  ·  view source on GitHub ↗

Marshal serializes a protobuf message as JSON into w.

(w io.Writer, m proto.Message)

Source from the content-addressed store, hash-verified

65
66// Marshal serializes a protobuf message as JSON into w.
67func (jm *Marshaler) Marshal(w io.Writer, m proto.Message) error {
68 b, err := jm.marshal(m)
69 if len(b) > 0 {
70 if _, err := w.Write(b); err != nil {
71 return err
72 }
73 }
74 return err
75}
76
77// MarshalToString serializes a protobuf message as JSON in string form.
78func (jm *Marshaler) MarshalToString(m proto.Message) (string, error) {

Callers

nothing calls this directly

Implementers 6

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

Calls 2

marshalMethod · 0.95
WriteMethod · 0.45

Tested by

no test coverage detected