File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright 2019 The Go Authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style
3+ // license that can be found in the LICENSE file.
4+
15package protojson
26
37import (
@@ -8,19 +12,30 @@ import (
812type MarshalOptions = protojson.MarshalOptions
913type UnmarshalOptions = protojson.UnmarshalOptions
1014
15+ // Format formats the message as a multiline string.
16+ // This function is only intended for human consumption and ignores errors.
17+ // Do not depend on the output being stable. Its output will change across
18+ // different builds of your program, even when using the same version of the
19+ // protobuf module.
1120func Format (m proto.Message ) string {
1221 return MarshalOptions {
1322 Multiline : true ,
1423 AllowPartial : true ,
1524 }.Format (m )
1625}
1726
27+ // Marshal writes the given [proto.Message] in JSON format using default options.
28+ // Do not depend on the output being stable. Its output will change across
29+ // different builds of your program, even when using the same version of the
30+ // protobuf module.
1831func Marshal (m proto.Message ) ([]byte , error ) {
1932 return MarshalOptions {
2033 AllowPartial : true ,
2134 }.Marshal (m )
2235}
2336
37+ // Unmarshal reads the given []byte into the given [proto.Message].
38+ // The provided message must be mutable (e.g., a non-nil pointer to a message).
2439func Unmarshal (b []byte , m proto.Message ) error {
2540 return UnmarshalOptions {
2641 AllowPartial : true ,
You can’t perform that action at this time.
0 commit comments