Involved Source Filesdecode.goencode.go
Package jsonpb provides functionality to marshal and unmarshal between a
protocol buffer message and JSON. It follows the specification at
https://developers.google.com/protocol-buffers/docs/proto3#json.
Do not rely on the default behavior of the standard encoding/json package
when called on generated message types as it does not operate correctly.
Deprecated: Use the "google.golang.org/protobuf/encoding/protojson"
package instead.
Package-Level Type Names (total 7, in which 5 are exported)
/* sort exporteds by: | */
AnyResolver takes a type URL, present in an Any message,
and resolves it into an instance of the associated message.
( AnyResolver) Resolve(typeURL string) (proto.Message, error)anyResolver
JSONPBMarshaler is implemented by protobuf messages that customize the
way they are marshaled to JSON. Messages that implement this should also
implement JSONPBUnmarshaler so that the custom format can be parsed.
The JSON marshaling must follow the proto to JSON specification:
https://developers.google.com/protocol-buffers/docs/proto3#json
Deprecated: Custom types should implement protobuf reflection instead.
( JSONPBMarshaler) MarshalJSONPB(*Marshaler) ([]byte, error)
JSONPBUnmarshaler is implemented by protobuf messages that customize the way
they are unmarshaled from JSON. Messages that implement this should also
implement JSONPBMarshaler so that the custom format can be produced.
The JSON unmarshaling must follow the JSON to proto specification:
https://developers.google.com/protocol-buffers/docs/proto3#json
Deprecated: Custom types should implement protobuf reflection instead.
( JSONPBUnmarshaler) UnmarshalJSONPB(*Unmarshaler, []byte) error
Marshaler is a configurable object for marshaling protocol buffer messages
to the specified JSON representation.
AnyResolver is used to resolve the google.protobuf.Any well-known type.
If unset, the global registry is used by default.
EmitDefaults specifies whether to render fields with zero values.
EnumsAsInts specifies whether to render enum values as integers,
as opposed to string values.
Indent controls whether the output is compact or not.
If empty, the output is compact JSON. Otherwise, every JSON object
entry and JSON array value will be on its own line.
Each line will be preceded by repeated copies of Indent, where the
number of copies is the current indentation depth.
OrigName specifies whether to use the original protobuf name for fields.
Marshal serializes a protobuf message as JSON into w.
MarshalToString serializes a protobuf message as JSON in string form.
(*Marshaler) marshal(m proto.Message) ([]byte, error)
func JSONPBMarshaler.MarshalJSONPB(*Marshaler) ([]byte, error)
Marshaler*Marshaler
AnyResolver is used to resolve the google.protobuf.Any well-known type.
If unset, the global registry is used by default.
EmitDefaults specifies whether to render fields with zero values.
EnumsAsInts specifies whether to render enum values as integers,
as opposed to string values.
Indent controls whether the output is compact or not.
If empty, the output is compact JSON. Otherwise, every JSON object
entry and JSON array value will be on its own line.
Each line will be preceded by repeated copies of Indent, where the
number of copies is the current indentation depth.
OrigName specifies whether to use the original protobuf name for fields.
buf[]byte
Marshal serializes a protobuf message as JSON into w.
MarshalToString serializes a protobuf message as JSON in string form.
( jsonWriter) marshal(m proto.Message) ([]byte, error)(*jsonWriter) marshalAny(m protoreflect.Message, indent string) error
marshalField writes field description and value to the Writer.
(*jsonWriter) marshalMessage(m protoreflect.Message, indent, typeURL string) error(*jsonWriter) marshalSingularValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error(*jsonWriter) marshalTypeURL(indent, typeURL string) error(*jsonWriter) marshalValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error(*jsonWriter) write(s string)(*jsonWriter) writeComma()
Package-Level Functions (total 11, in which 3 are exported)
Unmarshal unmarshals a JSON object from r into m.
UnmarshalNext unmarshals the next JSON object from d into m.
UnmarshalString unmarshals a JSON object from s into m.