Documentation
¶
Index ¶
- func ExpectByte(scanr *scanner.Scanner, xb byte) error
- func ParseNumber(scanr *scanner.Scanner) (*token.Scalar, error)
- func ParseString(scanr *scanner.Scanner) (*token.Scalar, error)
- func ReadDigits(scanr *scanner.Scanner) (byte, int, error)
- func UnexpectedByte(scanr *scanner.Scanner, expected string, args ...interface{}) error
- type Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseNumber ¶
ParseNumber parses a JSON number from the scanner. Exported for use by other format decoders.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads JSON input and streams it into a JSON stream.
func NewDecoder ¶
NewDecoder sets up a new Decoder instance to read from the given input.
func NewDecoderFromScanner ¶
NewDecoderFromScanner creates a decoder using an existing scanner. This is useful for format decoders that need to parse JSON values inline.
func (*Decoder) ParseValue ¶
parseValue reads a single JSON value and streams it. It can return a non-nil error if the input is invalid JSON.
type Encoder ¶
type Encoder struct {
format.Printer
*format.Colorizer
CompactWidthLimit int
CompactObjectMaxItems int
}
An Encoder can output a stream encoding a (stream of) JSON values using the given Printer instance for formatting.
func (*Encoder) Consume ¶
Consume formats the JSON stream encoded in the given channel using the instance's Printer. It assumes that the stream is well-formed, i.e. is a valid encoding for a stream of JSON values and may panic if that is not the case.
And error can be returned if the Printer could not perform some writing operation. A typical example is if it attempt to write to a closed pipe.