jsonpb

package
v3.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoGoDisallowUnknownFields

func GoGoDisallowUnknownFields()

GoGoDisallowUnknownFields enables option in decoder (unmarshaller) to return an error when it finds an unknown field. This function must be called before using the JSON marshaller.

func TTNEventStream

func TTNEventStream() runtime.Marshaler

TTNEventStream returns a TTN JsonPb marshaler with double newlines for text/event-stream compatibility.

Types

type GoGoDecoderWrapper

type GoGoDecoderWrapper struct {
	*json.Decoder
}

GoGoDecoderWrapper is a wrapper around a *json.Decoder that adds support for protos to the Decode method.

func (GoGoDecoderWrapper) Decode

func (d GoGoDecoderWrapper) Decode(v interface{}) error

Decode wraps the embedded decoder's Decode method to support protos using a jsonpb.Unmarshaler.

type GoGoJSONPb

type GoGoJSONPb jsonpb.Marshaler

GoGoJSONPb is a Marshaler which marshals/unmarshals into/from JSON with the "github.com/gogo/protobuf/jsonpb". It supports fully functionality of protobuf unlike JSONBuiltin.

The NewDecoder method returns a GoGoDecoderWrapper, so the underlying *json.Decoder methods can be used.

func (*GoGoJSONPb) ContentType

func (*GoGoJSONPb) ContentType() string

ContentType always returns "application/json".

func (*GoGoJSONPb) Delimiter

func (j *GoGoJSONPb) Delimiter() []byte

Delimiter for newline encoded JSON streams.

func (*GoGoJSONPb) Marshal

func (j *GoGoJSONPb) Marshal(v interface{}) ([]byte, error)

Marshal marshals "v" into JSON.

func (*GoGoJSONPb) NewDecoder

func (j *GoGoJSONPb) NewDecoder(r io.Reader) Decoder

NewDecoder returns a Decoder which reads JSON stream from "r".

func (*GoGoJSONPb) NewEncoder

func (j *GoGoJSONPb) NewEncoder(w io.Writer) Encoder

NewEncoder returns an Encoder which writes JSON stream into "w".

func (*GoGoJSONPb) Unmarshal

func (j *GoGoJSONPb) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals JSON "data" into "v"

type TTNDecoder added in v3.16.0

type TTNDecoder struct {
	// contains filtered or unexported fields
}

TTNDecoder reads JSON data from an io.Reader and unmarshals that into values.

func (*TTNDecoder) Decode added in v3.16.0

func (d *TTNDecoder) Decode(v any) error

Decode reads a value from the reader and unmarshals v from JSON.

type TTNEncoder added in v3.15.1

type TTNEncoder struct {
	// contains filtered or unexported fields
}

TTNEncoder marshals values to JSON and writes them to an io.Writer.

func (*TTNEncoder) Encode added in v3.15.1

func (e *TTNEncoder) Encode(v any) error

Encode marshals v to JSON and writes it to the writer.

type TTNMarshaler added in v3.15.1

type TTNMarshaler struct {
	*GoGoJSONPb
}

TTNMarshaler is the JSON marshaler/unmarshaler that is used in grpc-gateway.

func TTN

func TTN() *TTNMarshaler

TTN returns the default JSONPb marshaler of The Things Stack.

func (*TTNMarshaler) ContentType added in v3.15.1

func (*TTNMarshaler) ContentType() string

ContentType returns the content-type of the marshaler.

func (*TTNMarshaler) Marshal added in v3.15.1

func (m *TTNMarshaler) Marshal(v any) ([]byte, error)

Marshal marshals v to JSON.

func (*TTNMarshaler) NewDecoder added in v3.15.1

func (m *TTNMarshaler) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a new JSON decoder that reads data from r.

func (*TTNMarshaler) NewEncoder added in v3.15.1

func (m *TTNMarshaler) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns a new JSON encoder that writes values to w.

func (*TTNMarshaler) Unmarshal added in v3.15.1

func (m *TTNMarshaler) Unmarshal(data []byte, v any) error

Unmarshal unmarshals v from JSON data.

Jump to

Keyboard shortcuts

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