gojsonlex

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDelim

func IsDelim(c rune) bool

IsDelim reports whether the given rune is a JSON delimiter

Types

type JSONLexer

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

JSONLexer is a JSON lexical analyzer with streaming API support, where stream is a sequence of JSON tokens. JSONLexer does its own IO buffering so prefer low-level readers if you want to miminize memory footprint.

JSONLexer uses a ring buffer of fixed size (4096 bytes by default) and currently will fail if some token length exceeds the size of buffer, however you can tweak buffer size on JSONLexer creation.

JSONLexer uses unsafe pointers into the underlying buf to minimize allocations, see Token() for the provided guarantees.

func NewJSONLexer

func NewJSONLexer(r io.Reader) (*JSONLexer, error)

NewJSONLexer creates a new JSONLexer with the given reader.

func (*JSONLexer) SetBufSize

func (l *JSONLexer) SetBufSize(bufSize int)

SetBufSize creates a new buffer of the given size. MUST be called before parsing started.

func (*JSONLexer) SetSkipDelims

func (l *JSONLexer) SetSkipDelims(mustSkip bool)

SetSkipDelims tells JSONLexer to skip delimiters and return only keys and values. This can be useful in case you want to simply match the input to some specific grammar and have no intention of doing full syntax analysis.

func (*JSONLexer) Token

func (l *JSONLexer) Token() (Token, error)

Token returns the next JSON token. All strings returned by Token are guaranteed to be valid until the next Token call, otherwise you MUST make a deep copy.

type Token

type Token interface {
}

type TokenType

type TokenType byte

Jump to

Keyboard shortcuts

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