jsonpb

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Overview

Package jsonpb implements a JSON <> Protocol Buffer marshaler that supports more protocol buffer options thatn the default stdlib JSON marshaler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONPb

type JSONPb struct{}

JSONPb wraps Google's implementation of a JSON <> Protocol buffer marshaller that has more extented support for protocol buffer fields.

func (*JSONPb) ContentTypes

func (j *JSONPb) ContentTypes() []string

ContentTypes returns the content types the marshaller can handle.

func (*JSONPb) Exts

func (j *JSONPb) Exts() []string

Exts is a list of file extensions this marshaler supports.

func (*JSONPb) Marshal added in v0.2.0

func (j *JSONPb) Marshal(v any) ([]byte, error)

Marshal marshals any object into json bytes. Param v should be a pointer type.

func (*JSONPb) Marshals added in v0.2.0

func (j *JSONPb) Marshals(v any) bool

Marshals returns if this is able to encode the given type.

func (*JSONPb) Name added in v0.2.0

func (j *JSONPb) Name() string

Name returns the codec name.

func (*JSONPb) NewDecoder

func (j *JSONPb) NewDecoder(r io.Reader) codecs.Decoder

NewDecoder returns a new JSON/ProtocolBuffer decoder.

func (*JSONPb) NewEncoder

func (j *JSONPb) NewEncoder(w io.Writer) codecs.Encoder

NewEncoder returns a new JSON/ProtocolBuffer encoder.

func (*JSONPb) Unmarshal added in v0.2.0

func (j *JSONPb) Unmarshal(b []byte, v any) error

Unmarshal decodes json bytes into object v. Param v should be a pointer type.

func (*JSONPb) Unmarshals added in v0.2.0

func (j *JSONPb) Unmarshals(v any) bool

Unmarshals returns if this is able to decode the given type.

Jump to

Keyboard shortcuts

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