tokenizer

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ObjectStart indicates the start of JSON object.
	ObjectStart = '{' // {
	// ObjectEnd is the end of the JSON object.
	ObjectEnd = '}' // }
	// String is the start of JSON string.
	String = '"' // "
	// Colon indicates that the token is an object value.
	Colon = ':' // :
	// Comma indicates the next JSON element.
	Comma = ',' // ,
	// ArrayStart is the start of JSON array.
	ArrayStart = '[' // [
	// ArrayEnd is the end of JSON array.
	ArrayEnd = ']' // ]
	// True is 'true' token.
	True = 't' // t
	// False is 'false'.
	False = 'f' // f
	// Null is 'null' token.
	Null = 'n' // n
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

A Decoder decodes JSON values from an input stream.

func MakeDecoder

func MakeDecoder(data []byte) Decoder

MakeDecoder returns decoder for the input data

func (*Decoder) More

func (d *Decoder) More() bool

More returns true if there is more non-whitespace tokens available.

func (*Decoder) NextToken

func (d *Decoder) NextToken() ([]byte, error)

NextToken returns a []byte referencing the next logical token in the stream. The []byte is valid until Token is called again. At the end of the input stream, Token returns nil, io.EOF.

Token guarantees that the delimiters [ ] { } it returns are properly nested and matched: if Token encounters an unexpected delimiter in the input, it will return an error.

A valid token begins with one of the following:

{ Object start
[ Array start
} Object end
] Array End
t JSON true
f JSON false
n JSON null
" A string, possibly containing backslash escaped entites.
-, 0-9 A number

Commas and colons are elided.

func (*Decoder) Pos

func (d *Decoder) Pos() int

Pos returns current input position.

func (*Decoder) Release

func (d *Decoder) Release()

Release releases acquired resources.

type Scanner

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

Scanner implements a JSON scanner as defined in RFC 7159.

func (*Scanner) More

func (s *Scanner) More() bool

More returns true if scanner has more non-white space tokens.

func (*Scanner) Next

func (s *Scanner) Next() []byte

Next returns a []byte referencing the next lexical token in the stream. The []byte is valid until Next is called again. If the stream is at its end, or an error has occured, Next returns a zero length []byte slice.

A valid token begins with one of the following:

{ Object start
[ Array start
} Object end
] Array End
, Literal comma
: Literal colon
t JSON true
f JSON false
n JSON null
" A string, possibly containing backslash escaped entites.
-, 0-9 A number

func (*Scanner) Release

func (s *Scanner) Release()

Release releases scanner resources.

Jump to

Keyboard shortcuts

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