protomarshal

package
v0.0.0-...-d7df7b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 8

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyJSON

func ApplyJSON(js string, pb proto.Message) error

ApplyJSON unmarshals a JSON string into a proto message.

func ApplyJSONStrict

func ApplyJSONStrict(js string, pb proto.Message) error

ApplyJSONStrict unmarshals a JSON string into a proto message.

func ApplyYAML

func ApplyYAML(yml string, pb proto.Message) error

ApplyYAML unmarshals a YAML string into a proto message. Unknown fields are allowed.

func ApplyYAMLStrict

func ApplyYAMLStrict(yml string, pb proto.Message) error

ApplyYAMLStrict unmarshals a YAML string into a proto message. Unknown fields are not allowed.

func Marshal

func Marshal(msg proto.Message) ([]byte, error)

Marshal marshals a proto to canonical JSON

func MarshalIndent

func MarshalIndent(msg proto.Message, indent string) ([]byte, error)

MarshalIndent marshals a proto to canonical JSON with indentation

func MarshalIndentWithGlobalTypesResolver

func MarshalIndentWithGlobalTypesResolver(msg proto.Message, indent string) ([]byte, error)

MarshalIndentWithGlobalTypesResolver marshals a proto to canonical JSON with indentation and multiline while using generic types resolver

func MarshalProtoNames

func MarshalProtoNames(msg proto.Message) ([]byte, error)

MarshalProtoNames marshals a proto to canonical JSON original protobuf names

func ShallowCopy

func ShallowCopy(dst, src proto.Message)

func ToJSON

func ToJSON(msg proto.Message) (string, error)

ToJSON marshals a proto to canonical JSON

func ToJSONMap

func ToJSONMap(msg proto.Message) (map[string]any, error)

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 ToJSONWithAnyResolver

func ToJSONWithAnyResolver(msg proto.Message, indent string, anyResolver jsonpb.AnyResolver) (string, error)

func ToJSONWithIndent

func ToJSONWithIndent(msg proto.Message, indent string) (string, error)

ToJSONWithIndent marshals a proto to canonical JSON with pretty printed string

func ToJSONWithOptions

func ToJSONWithOptions(msg proto.Message, indent string, enumsAsInts bool) (string, error)

ToJSONWithOptions marshals a proto to canonical JSON with options to indent and print enums' int values

func ToYAML

func ToYAML(msg proto.Message) (string, error)

ToYAML marshals a proto to canonical YAML

func Unmarshal

func Unmarshal(b []byte, m proto.Message) error

func UnmarshalAllowUnknown

func UnmarshalAllowUnknown(b []byte, m proto.Message) error

func UnmarshalAllowUnknownWithAnyResolver

func UnmarshalAllowUnknownWithAnyResolver(anyResolver resolver, b []byte, m proto.Message) error

func UnmarshalString

func UnmarshalString(s string, m proto.Message) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL