Documentation ¶
Overview ¶
Package protomarshal provides operations to marshal and unmarshal protobuf objects. Unlike the rest of this repo, which uses the new google.golang.org/protobuf API, this package explicitly uses the legacy jsonpb package. This is due to a number of compatibility concerns with the new API: * https://github.com/golang/protobuf/issues/1374 * https://github.com/golang/protobuf/issues/1373
Index ¶
- func ApplyJSON(js string, pb proto.Message) error
- func ApplyJSONStrict(js string, pb proto.Message) error
- func ApplyYAML(yml string, pb proto.Message) error
- func ApplyYAMLStrict(yml string, pb proto.Message) error
- func Marshal(msg proto.Message) ([]byte, error)
- func MarshalIndent(msg proto.Message, indent string) ([]byte, error)
- func MarshalProtoNames(msg proto.Message) ([]byte, error)
- func ShallowCopy(dst, src proto.Message)
- func ToJSON(msg proto.Message) (string, error)
- func ToJSONMap(msg proto.Message) (map[string]interface{}, error)
- func ToJSONWithIndent(msg proto.Message, indent string) (string, error)
- func ToYAML(msg proto.Message) (string, error)
- func Unmarshal(b []byte, m proto.Message) error
- func UnmarshalAllowUnknown(b []byte, m proto.Message) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyJSONStrict ¶
ApplyJSONStrict unmarshals a JSON string into a proto message.
func ApplyYAML ¶
ApplyYAML unmarshals a YAML string into a proto message. Unknown fields are allowed.
func ApplyYAMLStrict ¶
ApplyYAMLStrict unmarshals a YAML string into a proto message. Unknown fields are not allowed.
func MarshalIndent ¶
MarshalIndent marshals a proto to canonical JSON with indentation
func MarshalProtoNames ¶
MarshalProtoNames marshals a proto to canonical JSON original protobuf names
func ShallowCopy ¶
func ToJSONMap ¶
ToJSONMap converts a proto message to a generic map using canonical JSON encoding JSON encoding is specified here: https://developers.google.com/protocol-buffers/docs/proto3#json
func ToJSONWithIndent ¶
ToJSONWithIndent marshals a proto to canonical JSON with pretty printed string
Types ¶
This section is empty.