Documentation
¶
Index ¶
- func Pretouch(vt reflect.Type, opts ...option.CompileOption) error
- func PretouchMany(vts []reflect.Type, opts ...option.CompileOption) error
- type Decoder
- func (self *Decoder) CheckTrailings() error
- func (self *Decoder) CopyString()
- func (self *Decoder) Decode(val interface{}) error
- func (self *Decoder) DisallowUnknownFields()
- func (self *Decoder) Pos() int
- func (self *Decoder) Reset(s string)
- func (self *Decoder) SetOptions(opts Options)
- func (self *Decoder) UseInt64()
- func (self *Decoder) UseNumber()
- func (self *Decoder) UseUnicodeErrors()
- func (self *Decoder) ValidateString()
- type MismatchTypeError
- type Options
- type StreamDecoder
- type SyntaxError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pretouch ¶
func Pretouch(vt reflect.Type, opts ...option.CompileOption) error
Pretouch compiles vt ahead-of-time to avoid JIT compilation on-the-fly, in order to reduce the first-hit latency.
Opts are the compile options, for example, "option.WithCompileRecursiveDepth" is a compile option to set the depth of recursive compile for the nested struct type.
func PretouchMany ¶ added in v1.15.1
func PretouchMany(vts []reflect.Type, opts ...option.CompileOption) error
PretouchMany compiles all vts ahead-of-time to avoid JIT compilation on-the-fly, in order to reduce the first-hit latency.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is the decoder context object
func (*Decoder) CheckTrailings ¶ added in v1.8.0
NOTE: api fallback do nothing
func (*Decoder) CopyString ¶ added in v1.1.1
func (self *Decoder) CopyString()
CopyString indicates the Decoder to decode string values by copying instead of referring.
func (*Decoder) Decode ¶
Decode parses the JSON-encoded data from current position and stores the result in the value pointed to by val.
func (*Decoder) DisallowUnknownFields ¶
func (self *Decoder) DisallowUnknownFields()
DisallowUnknownFields indicates the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
func (*Decoder) SetOptions ¶ added in v1.3.0
func (*Decoder) UseInt64 ¶
func (self *Decoder) UseInt64()
UseInt64 indicates the Decoder to unmarshal an integer into an interface{} as an int64 instead of as a float64.
func (*Decoder) UseNumber ¶
func (self *Decoder) UseNumber()
UseNumber indicates the Decoder to unmarshal a number into an interface{} as a json.Number instead of as a float64.
func (*Decoder) UseUnicodeErrors ¶
func (self *Decoder) UseUnicodeErrors()
UseUnicodeErrors indicates the Decoder to return an error when encounter invalid UTF-8 escape sequences.
func (*Decoder) ValidateString ¶ added in v1.4.0
func (self *Decoder) ValidateString()
ValidateString causes the Decoder to validate string values when decoding string value in JSON. Validation is that, returning error when unescaped control chars(0x00-0x1f) or invalid UTF-8 chars in the string value of JSON.
type MismatchTypeError ¶ added in v1.6.0
type MismatchTypeError json.UnmarshalTypeError
MismatchTypeError represents mismatching between json and object
type Options ¶ added in v1.3.0
type Options uint64
const ( OptionUseInt64 Options = 1 << _F_use_int64 OptionUseNumber Options = 1 << _F_use_number OptionUseUnicodeErrors Options = 1 << _F_disable_urc OptionDisableUnknown Options = 1 << _F_disable_unknown OptionCopyString Options = 1 << _F_copy_string OptionValidateString Options = 1 << _F_validate_string OptionNoValidateJSON Options = 1 << _F_no_validate_json OptionCaseSensitive Options = 1 << _F_case_sensitive )
type StreamDecoder ¶ added in v1.3.0
func NewStreamDecoder ¶ added in v1.3.0
func NewStreamDecoder(r io.Reader) *StreamDecoder
NewStreamDecoder adapts to encoding/json.NewDecoder API.
NewStreamDecoder returns a new decoder that reads from r.