jsonpb

package
v0.0.0-...-60b8695 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

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 TTN

func TTN() *GoGoJSONPb

TTN returns the default TTN JSONPb marshaler.

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"

Jump to

Keyboard shortcuts

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