json

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

type Converter struct {
	Parser               ProtoParser
	Filename             string
	Package, MessageType string
	Indent               bool
	EndOfMessageMarker   string
}

Converter converts proto message to json using definition provided by ProtoParser.

func (Converter) ConvertStream

func (c Converter) ConvertStream(r io.Reader) (resultCh chan []byte, errorCh chan error)

ConvertStream converts multiple proto messages to json. It returns a result channel and error channel which both can return multiple messages (a result or error for each message) Because proto messages often contain newlines, we can't rely on new lines for knowing when one message ends and the next begins, so instead it looks for a line containing only a specified marker (defaults to DefaultEndOfMessageMarker). Although unlikely, it is possible that the EndOfMessageMarker can be part of the proto binary message, in which case the parsing of that message will fail. If this happens, use a more complex EndOfMessageMarker.

type ProtoParser

type ProtoParser interface {
	ParseFiles(filenames ...string) ([]*desc.FileDescriptor, error)
}

ProtoParser defines the interface for parsing proto files dynamically.

Jump to

Keyboard shortcuts

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