package jsonpb

import "github.com/docker/distribution/Godeps/_workspace/src/github.com/golang/protobuf/jsonpb"

Package jsonpb provides marshalling/unmarshalling functionality between protocol buffer and JSON objects.

Compared to encoding/json, this library:

Index

Functions

func Unmarshal

func Unmarshal(r io.Reader, pb proto.Message) error

Unmarshal unmarshals a JSON object stream into a protocol buffer. This function is lenient and will decode any options permutations of the related Marshaller.

func UnmarshalString

func UnmarshalString(str string, pb proto.Message) error

UnmarshalString will populate the fields of a protocol buffer based on a JSON string. This function is lenient and will decode any options permutations of the related Marshaller.

Types

type Marshaller

type Marshaller struct {
	// Use string values for enums (as opposed to integer values)
	EnumsAsString bool

	// A string to indent each level by. The presence of this field will
	// also cause a space to appear between the field separator and
	// value, and for newlines to be appear between fields and array
	// elements.
	Indent string
}

Marshaller is a configurable object for converting between protocol buffer objects and a JSON representation for them

func (*Marshaller) Marshal

func (m *Marshaller) Marshal(out io.Writer, pb proto.Message) error

Marshal marshals a protocol buffer into JSON.

func (*Marshaller) MarshalToString

func (m *Marshaller) MarshalToString(pb proto.Message) (string, error)

MarshalToString converts a protocol buffer object to JSON string.

Source Files

jsonpb.go

Version
v2.2.1+incompatible
Published
Dec 9, 2015
Platform
linux/amd64
Imports
9 packages
Last checked
7 hours ago

Tools for package owners.