yaml

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuessJSONStream added in v1.1.3

func GuessJSONStream(r io.Reader, size int) (io.Reader, bool)

GuessJSONStream scans the provided reader up to size, looking for an open brace indicating this is JSON. It will return the bufio.Reader it creates for the consumer.

func ToJSON

func ToJSON(data []byte) ([]byte, error)

ToJSON converts a single YAML document into a JSON document or returns an error. If the document appears to be JSON the YAML decoding path is not used (so that error messages are JSON specific).

Types

type YAMLOrJSONDecoder

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

YAMLOrJSONDecoder attempts to decode a stream of JSON documents or YAML documents by sniffing for a leading { character.

func NewYAMLOrJSONDecoder

func NewYAMLOrJSONDecoder(r io.Reader, bufferSize int) *YAMLOrJSONDecoder

NewYAMLOrJSONDecoder returns a decoder that will process YAML documents or JSON documents from the given reader as a stream. bufferSize determines how far into the stream the decoder will look to figure out whether this is a JSON stream (has whitespace followed by an open brace).

func (*YAMLOrJSONDecoder) Decode

func (d *YAMLOrJSONDecoder) Decode(into interface{}) error

Decode unmarshals the next object from the underlying stream into the provide object, or returns an error.

type YAMLToJSONDecoder

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

YAMLToJSONDecoder decodes YAML documents from an io.Reader by separating individual documents. It first converts the YAML body to JSON, then unmarshals the JSON.

func NewYAMLToJSONDecoder

func NewYAMLToJSONDecoder(r io.Reader) *YAMLToJSONDecoder

NewYAMLToJSONDecoder decodes YAML documents from the provided stream in chunks by converting each document (as defined by the YAML spec) into its own chunk, converting it to JSON via yaml.YAMLToJSON, and then passing it to json.Decoder.

func (*YAMLToJSONDecoder) Decode

func (d *YAMLToJSONDecoder) Decode(into interface{}) error

Decode reads a YAML document as JSON from the stream or returns an error. The decoding rules match json.Unmarshal, not yaml.Unmarshal.

Jump to

Keyboard shortcuts

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