Documentation ¶
Index ¶
- Constants
- func ParseBool(b []byte) (bool, error)
- func ParseFloat32(b []byte) (float32, error)
- func ParseFloat64(b []byte) (float64, error)
- func ParseInt32(b []byte) (int32, error)
- func ParseInt64(b []byte) (int64, error)
- func ParseUint32(b []byte) (uint32, error)
- func ParseUint64(b []byte) (uint64, error)
- func UnquoteBytes(s []byte) (t []byte, ok bool)
- func UnquoteString(b []byte) (s string, ok bool)
- type Decoder
- func (d *Decoder) ArrayAfterReadValue() (stop bool)
- func (d *Decoder) ArrayBeforeReadValue() (stop bool)
- func (d *Decoder) ObjectAfterReadValue() (stop bool)
- func (d *Decoder) ObjectBeforeReadKey() (stop bool)
- func (d *Decoder) ObjectBeforeReadValue()
- func (d *Decoder) ReadIndex() int
- func (d *Decoder) ReadItem() []byte
- func (d *Decoder) ReadObjectKey() string
- func (d *Decoder) RescanLiteral()
- func (d *Decoder) ScanError() error
- func (d *Decoder) ScanNext()
- func (d *Decoder) ScanWhile(op OpCode)
- func (d *Decoder) Skip()
- type InvalidUnmarshalError
- type OpCode
- type ParsePhase
- type SyntaxError
- type UnmarshalTypeError
Constants ¶
const PhasePanicMsg = "JSON decoder out of sync - data changing underfoot?"
PhasePanicMsg is used as a panic message when we end up with something that shouldn't happen. It can indicate a bug in the JSON decoder, or that something is editing the data slice while the decoder executes.
Variables ¶
This section is empty.
Functions ¶
func ParseFloat32 ¶
func ParseFloat64 ¶
func ParseInt32 ¶
func ParseInt64 ¶
func ParseUint32 ¶
func ParseUint64 ¶
func UnquoteBytes ¶
func UnquoteString ¶
UnquoteString converts a quoted JSON string literal s into an actual string t. The rules are different than for Go, so cannot use strconv.Unquote.
Types ¶
type Decoder ¶
type Decoder struct { OpCode OpCode // last read result // contains filtered or unexported fields }
func (*Decoder) ArrayAfterReadValue ¶
func (*Decoder) ArrayBeforeReadValue ¶
func (*Decoder) ObjectAfterReadValue ¶
func (*Decoder) ObjectBeforeReadKey ¶
func (*Decoder) ObjectBeforeReadValue ¶
func (d *Decoder) ObjectBeforeReadValue()
func (*Decoder) ReadObjectKey ¶
ReadObjectKey Read key of object or map.
func (*Decoder) RescanLiteral ¶
func (d *Decoder) RescanLiteral()
RescanLiteral is similar to scanWhile(ScanContinue), but it specialises the gojson case where we're decoding a literal. The decoder scans the input twice, once for syntax errors and to check the length of the value, and the second to perform the decoding.
Only in the second step do we use decodeState to tokenize literals, so we know there aren't any syntax errors. We can take advantage of that knowledge, and scan a literal's bytes much more quickly.
func (*Decoder) ScanNext ¶
func (d *Decoder) ScanNext()
ScanNext processes the byte at d.data[d.off].
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type OpCode ¶
type OpCode int8
const ( // Continue. ScanContinue OpCode = iota // uninteresting byte ScanBeginLiteral // end implied by next result != ScanContinue ScanBeginObject // begin object ScanObjectKey // just finished object key (string) ScanObjectValue // just finished non-last object value ScanEndObject // end object (implies ScanObjectValue if possible) ScanBeginArray // begin array ScanArrayValue // just finished array value ScanEndArray // end array (implies ScanArrayValue if possible) ScanSkipSpace // space byte; can skip; known to be last "continue" result // Stop. ScanEnd // top-level value ended *before* this byte; known to be first "stop" result ScanError // hit an error, scanner.err. )
These values are returned by the state transition functions assigned to scanner.state and the method scanner.eof. They give details about the current state of the scan that callers might be interested to know about. It is okay to ignore the return value of any particular call to scanner.state: if one call returns ScanError, every subsequent call will return ScanError too.
type ParsePhase ¶
type ParsePhase int8
type SyntaxError ¶
type SyntaxError struct { Offset int64 // error occurred after reading Offset bytes // contains filtered or unexported fields }
A SyntaxError is a description of a JSON syntax error.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnmarshalTypeError ¶
type UnmarshalTypeError struct { Value string // description of JSON value - "bool", "array", "number -5" Type reflect.Type // type of Go value it could not be assigned to Offset int64 // error occurred after reading Offset bytes Struct string // name of the struct type containing the field Field string // the full path from root node to the field }
An UnmarshalTypeError describes a JSON value that was not appropriate for a value of a specific Go type.
func (*UnmarshalTypeError) Error ¶
func (e *UnmarshalTypeError) Error() string