Documentation ¶
Overview ¶
see encoding/json * - some additional comments may be added * - some code may be slightly modified
see encoding/json * - some additional comments may be added * - some code may be slightly modified
see encoding/json * - some additional comments may be added * - some code may be slightly modified
see encoding/json * - some additional comments may be added * - some code may be slightly modified
Index ¶
- Variables
- func Marshal(o interface{}) ([]byte, error)
- func ReturnIterator(it *Iterator)
- func ReturnStreamer(s *Streamer)
- func Unmarshal(data []byte, o interface{}) error
- func UnmarshalFromReader(r io.Reader, o interface{}) error
- func Valid(data []byte) bool
- type BadQuotedStringError
- type DecOpts
- type DecodeError
- type Decoder
- func (dec *Decoder) NewIterator() *Iterator
- func (dec *Decoder) ReturnIterator(it *Iterator)
- func (dec *Decoder) Unmarshal(data []byte, obj interface{}) error
- func (dec *Decoder) UnmarshalFromReader(r io.Reader, obj interface{}) error
- func (dec *Decoder) UnmarshalFromString(s string, obj interface{}) error
- type DecoderOption
- type EncOpts
- type Encoder
- type EncoderOption
- type IntOverflowError
- type InvalidDigitError
- type InvalidEscapeCharError
- type InvalidFloatError
- type InvalidStringCharError
- type InvalidUnicodeCharError
- type Iterator
- func (it *Iterator) AppendRaw(in []byte) ([]byte, error)
- func (it *Iterator) Buffer() []byte
- func (it *Iterator) NextValueType() (ValueType, error)
- func (it *Iterator) Read() (interface{}, error)
- func (it *Iterator) ReadArrayBegin() (ret bool, err error)
- func (it *Iterator) ReadArrayCB(cb func(*Iterator) error) error
- func (it *Iterator) ReadArrayMore() (ret bool, err error)
- func (it *Iterator) ReadBool() (bool, error)
- func (it *Iterator) ReadFloat32() (float32, error)
- func (it *Iterator) ReadFloat64() (float64, error)
- func (it *Iterator) ReadInt() (int, error)
- func (it *Iterator) ReadInt16() (int16, error)
- func (it *Iterator) ReadInt32() (int32, error)
- func (it *Iterator) ReadInt64() (int64, error)
- func (it *Iterator) ReadInt8() (int8, error)
- func (it *Iterator) ReadNull() error
- func (it *Iterator) ReadNumber() (n Number, err error)
- func (it *Iterator) ReadObjectBegin() (_ bool, _ string, err error)
- func (it *Iterator) ReadObjectCB(cb func(it *Iterator, field string) error) error
- func (it *Iterator) ReadObjectMore() (_ bool, _ string, err error)
- func (it *Iterator) ReadRaw() ([]byte, error)
- func (it *Iterator) ReadString() (ret string, err error)
- func (it *Iterator) ReadStringAndAppend(buf []byte) (_ []byte, err error)
- func (it *Iterator) ReadStringAsSlice() (_ []byte, err error)
- func (it *Iterator) ReadUint() (uint, error)
- func (it *Iterator) ReadUint16() (uint16, error)
- func (it *Iterator) ReadUint32() (uint32, error)
- func (it *Iterator) ReadUint64() (uint64, error)
- func (it *Iterator) ReadUint8() (uint8, error)
- func (it *Iterator) ReadVal(obj interface{}) error
- func (it *Iterator) Reset(r io.Reader)
- func (it *Iterator) ResetBytes(data []byte)
- func (it *Iterator) Skip() error
- func (it *Iterator) SkipArray() error
- func (it *Iterator) SkipNumber() error
- func (it *Iterator) SkipObject() error
- func (it *Iterator) SkipRaw() ([]byte, error)
- func (it *Iterator) SkipString() error
- func (it *Iterator) Unmarshal(data []byte, obj interface{}) error
- func (it *Iterator) UnmarshalFromReader(r io.Reader, obj interface{}) error
- func (it *Iterator) Valid(data []byte) bool
- func (it *Iterator) WrapError(err error) *DecodeError
- type IteratorPool
- type Number
- type Streamer
- func (s *Streamer) ArrayEnd() *Streamer
- func (s *Streamer) ArrayStart() *Streamer
- func (s *Streamer) Bool(b bool) *Streamer
- func (s *Streamer) False() *Streamer
- func (s *Streamer) Field(field string) *Streamer
- func (s *Streamer) Float32(f float32) *Streamer
- func (s *Streamer) Float64(f float64) *Streamer
- func (s *Streamer) Flush() error
- func (s *Streamer) Int(v int) *Streamer
- func (s *Streamer) Int16(v int16) *Streamer
- func (s *Streamer) Int32(v int32) *Streamer
- func (s *Streamer) Int64(v int64) *Streamer
- func (s *Streamer) Int8(v int8) *Streamer
- func (s *Streamer) Null() *Streamer
- func (s *Streamer) ObjectEnd() *Streamer
- func (s *Streamer) ObjectStart() *Streamer
- func (s *Streamer) Raw(raw []byte) *Streamer
- func (s *Streamer) RawField(b []byte) *Streamer
- func (s *Streamer) RawString(raw string) *Streamer
- func (s *Streamer) Reset(w io.Writer)
- func (s *Streamer) String(str string) *Streamer
- func (s *Streamer) True() *Streamer
- func (s *Streamer) Uint(v uint) *Streamer
- func (s *Streamer) Uint16(v uint16) *Streamer
- func (s *Streamer) Uint32(v uint32) *Streamer
- func (s *Streamer) Uint64(v uint64) *Streamer
- func (s *Streamer) Uint8(v uint8) *Streamer
- func (s *Streamer) Value(obj interface{}) *Streamer
- type StreamerPool
- type TypeNotSupportedError
- type UnexpectedByteError
- type UnknownFieldError
- type ValDecoder
- type ValEncoder
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var DataRemainedError = errors.New("expecting EOF, but there is still data")
DataRemainedError
var ( // default decoder is compatible with standard lib DefaultDecoder = NewDecoder(nil) )
var (
DefaultEncoder = NewEncoder(nil)
)
var EfaceLoopingError = errors.New("eface looping detected")
EfaceLoopingError
var FloatIsInfinity = errors.New("float is infinity")
var FloatIsNan = errors.New("float is NaN")
var IFaceError = errors.New("cannot unmarshal on empty iface")
IFaceError
var NilEmbeddedPointerError = errors.New("cannot unmarshal on nil pointer (unexported embedded)")
NilEmbeddedError
var NilPointerReceiverError = errors.New("the receiver is nil")
NilPointerReceiverError
var NoWriterAttachedError = errors.New("no writer attached")
var PointerReceiverError = errors.New("the receiver is not a pointer")
PointerReceiverError
Functions ¶
func ReturnIterator ¶
func ReturnIterator(it *Iterator)
func ReturnStreamer ¶
func ReturnStreamer(s *Streamer)
func UnmarshalFromReader ¶ added in v0.0.4
Types ¶
type BadQuotedStringError ¶
type BadQuotedStringError string
BadQuotedString
func (BadQuotedStringError) Error ¶
func (e BadQuotedStringError) Error() string
type DecodeError ¶
type DecodeError struct {
// contains filtered or unexported fields
}
func (*DecodeError) Error ¶
func (e *DecodeError) Error() string
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder(opt *DecoderOption) *Decoder
func (*Decoder) NewIterator ¶
func (*Decoder) ReturnIterator ¶
func (*Decoder) UnmarshalFromReader ¶ added in v0.0.3
func (*Decoder) UnmarshalFromString ¶
type DecoderOption ¶
type DecoderOption struct { // custom value decoders ValDecoders map[reflect.Type]ValDecoder // if the object key is case sensitive // `false` by default CaseSensitive bool // the tag name for structures // `json` by default Tag string OnlyTaggedField bool UseNumber bool DisallowUnknownFields bool }
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder(opt *EncoderOption) *Encoder
func (*Encoder) NewStreamer ¶
func (*Encoder) ReturnStreamer ¶
type EncoderOption ¶
type IntOverflowError ¶
type IntOverflowError struct {
// contains filtered or unexported fields
}
IntOverflow
func (IntOverflowError) Error ¶
func (e IntOverflowError) Error() string
type InvalidDigitError ¶
type InvalidDigitError struct {
// contains filtered or unexported fields
}
InvalidDigit
func (InvalidDigitError) Error ¶
func (e InvalidDigitError) Error() string
type InvalidEscapeCharError ¶
type InvalidEscapeCharError struct {
// contains filtered or unexported fields
}
InvalidEscapeCharError
func (InvalidEscapeCharError) Error ¶
func (e InvalidEscapeCharError) Error() string
type InvalidFloatError ¶
type InvalidFloatError struct {
// contains filtered or unexported fields
}
InvalidFloat
func (InvalidFloatError) Error ¶
func (e InvalidFloatError) Error() string
type InvalidStringCharError ¶
type InvalidStringCharError struct {
// contains filtered or unexported fields
}
InvalidStringCharError
func (InvalidStringCharError) Error ¶
func (e InvalidStringCharError) Error() string
type InvalidUnicodeCharError ¶
type InvalidUnicodeCharError struct {
// contains filtered or unexported fields
}
InvalidUnicodeCharError
func (InvalidUnicodeCharError) Error ¶
func (e InvalidUnicodeCharError) Error() string
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func NewIterator ¶
func NewIterator() *Iterator
func (*Iterator) NextValueType ¶
Read until the first valid token is found, only the whitespaces are consumed
func (*Iterator) ReadArrayBegin ¶
* var ( * more bool * err error * ) * for more, err = it.ReadArray(); * more; * more, err = it.ReadArrayMore() { * } * if err != nil { * // error handling * }
func (*Iterator) ReadArrayMore ¶
func (*Iterator) ReadFloat32 ¶
func (*Iterator) ReadFloat64 ¶
func (*Iterator) ReadNumber ¶
func (*Iterator) ReadObjectBegin ¶
func (*Iterator) ReadObjectCB ¶
func (*Iterator) ReadObjectMore ¶
func (*Iterator) ReadString ¶
func (*Iterator) ReadStringAndAppend ¶
func (*Iterator) ReadStringAsSlice ¶
The returned slice can only be used temporarily, a copy must be made if the result needs to be saved
func (*Iterator) ReadUint16 ¶
func (*Iterator) ReadUint32 ¶
func (*Iterator) ReadUint64 ¶
func (*Iterator) Reset ¶
* In reset methods, explicit assignment is faster than then following * *it = Iterator{ ... } * When the above code is used, runtime.duffcopy and runtime.duffzero will be used * which will slow down our code (correct me if I am wrong)
func (*Iterator) ResetBytes ¶
func (*Iterator) SkipNumber ¶
func (*Iterator) SkipObject ¶
func (*Iterator) SkipString ¶
func (*Iterator) UnmarshalFromReader ¶ added in v0.0.3
func (*Iterator) WrapError ¶
func (it *Iterator) WrapError(err error) *DecodeError
type IteratorPool ¶
type IteratorPool struct {
// contains filtered or unexported fields
}
func NewIteratorPool ¶
func NewIteratorPool() *IteratorPool
func (*IteratorPool) BorrowIterator ¶
func (p *IteratorPool) BorrowIterator() *Iterator
func (*IteratorPool) ReturnIterator ¶
func (p *IteratorPool) ReturnIterator(it *Iterator)
type Streamer ¶
type Streamer struct { Error error Context interface{} // custom stream context // contains filtered or unexported fields }
func NewStreamer ¶
func NewStreamer() *Streamer
func (*Streamer) ArrayStart ¶
func (*Streamer) ObjectStart ¶
type StreamerPool ¶
type StreamerPool struct {
// contains filtered or unexported fields
}
func NewStreamerPool ¶
func NewStreamerPool() *StreamerPool
func (*StreamerPool) BorrowStreamer ¶
func (p *StreamerPool) BorrowStreamer() *Streamer
func (*StreamerPool) ReturnStreamer ¶
func (p *StreamerPool) ReturnStreamer(s *Streamer)
type TypeNotSupportedError ¶
type TypeNotSupportedError string
TypeNotSupported
func (TypeNotSupportedError) Error ¶
func (e TypeNotSupportedError) Error() string
type UnexpectedByteError ¶
type UnexpectedByteError struct {
// contains filtered or unexported fields
}
UnexpectedByteError
func (UnexpectedByteError) Error ¶
func (e UnexpectedByteError) Error() string
type UnknownFieldError ¶
type UnknownFieldError string
UnknownField
func (UnknownFieldError) Error ¶
func (e UnknownFieldError) Error() string
type ValDecoder ¶
type ValEncoder ¶
Source Files ¶
- convert.go
- decoder.go
- decoder_iterator.go
- eface.go
- encoder.go
- encoder_streamer.go
- errors_decoder.go
- errors_encoder.go
- helper.go
- iface.go
- is_empty.go
- iterator.go
- iterator_array.go
- iterator_bool.go
- iterator_float.go
- iterator_float32.go
- iterator_float64.go
- iterator_int.go
- iterator_int16.go
- iterator_int32.go
- iterator_int64.go
- iterator_int8.go
- iterator_null.go
- iterator_number.go
- iterator_object.go
- iterator_pool.go
- iterator_raw.go
- iterator_read.go
- iterator_read_array.go
- iterator_read_object.go
- iterator_skip.go
- iterator_skip_array.go
- iterator_skip_number.go
- iterator_skip_object.go
- iterator_skip_str.go
- iterator_str.go
- iterator_val.go
- link_reflect.go
- node.go
- number.go
- pool.go
- stack.go
- standard_compatible.go
- streamer.go
- streamer_float.go
- streamer_int.go
- streamer_pool.go
- streamer_str.go
- streamer_val.go
- struct.go
- struct_field.go
- struct_field_fold.go
- struct_field_upper.go
- struct_tag.go
- type_queue.go
- val_decoder.go
- val_decoder_json_number.go
- val_decoder_json_rawmessage.go
- val_decoder_json_unmarshaler.go
- val_decoder_native.go
- val_decoder_native_array.go
- val_decoder_native_float.go
- val_decoder_native_int.go
- val_decoder_native_interface.go
- val_decoder_native_map.go
- val_decoder_native_ptr.go
- val_decoder_native_slice.go
- val_decoder_native_struct.go
- val_decoder_native_struct_one_field.go
- val_decoder_native_struct_small.go
- val_decoder_native_uint.go
- val_decoder_skip.go
- val_decoder_text_unmarshaler.go
- val_encoder.go
- val_encoder_direct.go
- val_encoder_json_marshaler.go
- val_encoder_json_number.go
- val_encoder_json_rawmessage.go
- val_encoder_native.go
- val_encoder_native_array.go
- val_encoder_native_base64.go
- val_encoder_native_float.go
- val_encoder_native_int.go
- val_encoder_native_interface.go
- val_encoder_native_map.go
- val_encoder_native_ptr.go
- val_encoder_native_slice.go
- val_encoder_native_struct.go
- val_encoder_native_uint.go
- val_encoder_text_marshaler.go
- value_type.go