Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ClientCancelledParse = &Error{
e: "client cancelled parse",
}
Error code returned from .Parse() when callback returns false.
var PageSize = uintptr(os.Getpagesize())
Global PageSize variable so a sys call is not made each time
Functions ¶
func ReadJSONNL ¶
ReadJSONNL - Read and parse newline separated JSON from an `io.Reader` invoke callback with each token. Terminate if callback returns false. arguments to callback:
t - token type key - key if parsing object key / value pairs value - decoded value line - line offset in file. Distinct documents are indicated by a distinct line number.
Types ¶
type Callback ¶
Callback is the signature of the client callback to the parsing routine. The routine is passed the type of entity parsed, a key if relevant (parsing inside an object), and a decoded value.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
The Error object is provided by the Parser when an error is encountered.
type OffsetCallback ¶
OffsetCallback is the signature of the client callback to the offset parsing routine.
The routine is passed the type of entity parsed, a key if relevant (parsing inside an object), and the start and end offset of the value.
The start offset is inclusive and the end offset is exclusive, which allows for callers to simply re-slice their buffers with the received data without any manipulation.
There are corner cases for opening and closing of arrays and objects, on those scenarios the caller will receive the start value and -1 for end and -1 and end value respectively.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the primary object provided by goj via the NewParser method. The various parsing routines are provided by this object, but it has no exported fields.
func NewParser ¶
func NewParser() *Parser
NewParser - Allocate a new JSON Scanner that may be re-used.
func (*Parser) OffsetParse ¶
func (p *Parser) OffsetParse(buf []byte, cb OffsetCallback) error
OffsetParse implements lazy parsing that allows for callers to decide how to read data from the byte slices.
The callbacks will receive the indices of the raw data without any parsing, so the caller is responsible for any decoding if needed. The only exception for this is when it's a key object, in that case the parser will decode data before calling the callback.
type Type ¶
type Type uint8
Type represents the JSON value type.
const ( // String represents a JSON string. String Type = iota // Integer represents a JSON number known to be a uint. Integer // NegInteger represents a JSON number known to be an int. NegInteger // Float represents a JSON number that is neither an int or uint. Float // True represents the JSON boolean 'true'. True // False represents the JSON boolean 'false'. False // Null represents the JSON null value. Null // Array represents the beginning of a JSON array. Array // ArrayEnd represents the end of a JSON array. ArrayEnd // Object represents the beginning of a JSON object. Object // ObjectEnd represents the end of a JSON object. ObjectEnd // SkippedData represent the []byte of data that was skipped. SkippedData )