Documentation ¶
Index ¶
- Constants
- Variables
- func CleanDecoders()
- func Marshal(v interface{}) ([]byte, error)
- func MarshalToString(v interface{}) (string, error)
- func RegisterExtension(extension ExtensionFunc)
- func RegisterFieldDecoder(typ string, field string, fun DecoderFunc)
- func RegisterFieldEncoder(typ string, field string, fun EncoderFunc)
- func RegisterTypeDecoder(typ string, fun DecoderFunc)
- func RegisterTypeEncoder(typ string, fun EncoderFunc)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalFromString(str string, v interface{}) error
- func WriteToStream(val interface{}, stream *Stream, encoder Encoder)
- type Any
- func UnmarshalAny(data []byte) (Any, error)
- func UnmarshalAnyFromString(str string) (Any, error)
- func Wrap(val interface{}) Any
- func WrapFloat64(val float64) Any
- func WrapInt32(val int32) Any
- func WrapInt64(val int64) Any
- func WrapString(val string) Any
- func WrapUint32(val uint32) Any
- func WrapUint64(val uint64) Any
- type Decoder
- type DecoderFunc
- type Encoder
- type EncoderFunc
- type ExtensionFunc
- type Extract
- type ExtractMany
- type Field
- type IKey
- type Index
- type Iterator
- func (iter *Iterator) CurrentBuffer() string
- func (iter *Iterator) Read() interface{}
- func (iter *Iterator) ReadAny() Any
- func (iter *Iterator) ReadArray() (ret bool)
- func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool)
- func (iter *Iterator) ReadBase64() (ret []byte)
- func (iter *Iterator) ReadBool() (ret bool)
- func (iter *Iterator) ReadFloat32() (ret float32)
- func (iter *Iterator) ReadFloat64() (ret float64)
- func (iter *Iterator) ReadInt() int
- func (iter *Iterator) ReadInt16() (ret int16)
- func (iter *Iterator) ReadInt32() (ret int32)
- func (iter *Iterator) ReadInt64() (ret int64)
- func (iter *Iterator) ReadInt8() (ret int8)
- func (iter *Iterator) ReadNil() (ret bool)
- func (iter *Iterator) ReadObject() (ret string)
- func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool
- func (iter *Iterator) ReadString() (ret string)
- func (iter *Iterator) ReadStringAsSlice() (ret []byte)
- func (iter *Iterator) ReadUint() uint
- func (iter *Iterator) ReadUint16() (ret uint16)
- func (iter *Iterator) ReadUint32() (ret uint32)
- func (iter *Iterator) ReadUint64() uint64
- func (iter *Iterator) ReadUint8() (ret uint8)
- func (iter *Iterator) ReadVal(obj interface{})
- func (iter *Iterator) Reset(reader io.Reader) *Iterator
- func (iter *Iterator) ResetBytes(input []byte) *Iterator
- func (iter *Iterator) Skip()
- func (iter *Iterator) WhatIsNext() ValueType
- type KeyBool
- type KeyFloat64
- type KeyInt64
- type KeyReader
- type KeyString
- type Path
- type Stream
- func (b *Stream) Available() int
- func (b *Stream) Buffered() int
- func (b *Stream) Flush() error
- func (b *Stream) Reset(out io.Writer)
- func (b *Stream) Write(p []byte) (nn int, err error)
- func (stream *Stream) WriteArrayEnd()
- func (stream *Stream) WriteArrayStart()
- func (stream *Stream) WriteBool(val bool)
- func (stream *Stream) WriteEmptyArray()
- func (stream *Stream) WriteEmptyObject()
- func (stream *Stream) WriteFalse()
- func (stream *Stream) WriteFloat32(val float32)
- func (stream *Stream) WriteFloat64(val float64)
- func (stream *Stream) WriteInt(val int)
- func (stream *Stream) WriteInt16(nval int16)
- func (stream *Stream) WriteInt32(nval int32)
- func (stream *Stream) WriteInt64(nval int64)
- func (stream *Stream) WriteInt8(nval int8)
- func (stream *Stream) WriteMore()
- func (stream *Stream) WriteNil()
- func (stream *Stream) WriteObjectEnd()
- func (stream *Stream) WriteObjectField(field string)
- func (stream *Stream) WriteObjectStart()
- func (b *Stream) WriteRaw(s string)
- func (stream *Stream) WriteString(s string)
- func (stream *Stream) WriteTrue()
- func (stream *Stream) WriteUint(val uint)
- func (stream *Stream) WriteUint16(val uint16)
- func (stream *Stream) WriteUint32(val uint32)
- func (stream *Stream) WriteUint64(val uint64)
- func (stream *Stream) WriteUint8(val uint8)
- func (stream *Stream) WriteVal(val interface{})
- type ValueType
Constants ¶
const ( // Missed represent not follow the path Missed int = 0 // FollowThePath represent follow the path FollowThePath int = 1 )
const ( // TypeObject value will be a object TypeObject int = 0 // TypeArray value will be a array TypeArray int = 1 )
Variables ¶
var ( // ErrInvalidPath represent a invalid path ErrInvalidPath = errors.New("Invalid Path") // ErrInvalidKeyReader represent not set a correct reader ErrInvalidKeyReader = errors.New("Invalid Key Reader") )
var DECODERS unsafe.Pointer
var DIGITS []uint32
var ENCODERS unsafe.Pointer
var POW10 []uint64
Functions ¶
func MarshalToString ¶
func RegisterExtension ¶
func RegisterExtension(extension ExtensionFunc)
RegisterExtension can register a custom extension
func RegisterFieldDecoder ¶
func RegisterFieldDecoder(typ string, field string, fun DecoderFunc)
RegisterFieldDecoder can register a type for json field
func RegisterFieldEncoder ¶
func RegisterFieldEncoder(typ string, field string, fun EncoderFunc)
func RegisterTypeDecoder ¶
func RegisterTypeDecoder(typ string, fun DecoderFunc)
RegisterTypeDecoder can register a type for json object
func RegisterTypeEncoder ¶
func RegisterTypeEncoder(typ string, fun EncoderFunc)
func UnmarshalFromString ¶
func WriteToStream ¶
Types ¶
type Any ¶
type Any interface { LastError() error ValueType() ValueType ToBool() bool ToInt() int ToInt32() int32 ToInt64() int64 ToUint() uint ToUint32() uint32 ToUint64() uint64 ToFloat32() float32 ToFloat64() float64 ToString() string Get(path ...interface{}) Any Size() int Keys() []string IterateObject() (func() (string, Any, bool), bool) IterateArray() (func() (Any, bool), bool) GetArray() []Any SetArray(newList []Any) bool GetObject() map[string]Any SetObject(map[string]Any) bool GetInterface() interface{} WriteTo(stream *Stream) Parse() *Iterator }
func UnmarshalAny ¶
func UnmarshalAnyFromString ¶
func WrapFloat64 ¶
func WrapString ¶
func WrapUint32 ¶
func WrapUint64 ¶
type DecoderFunc ¶
type EncoderFunc ¶
type ExtensionFunc ¶
type ExtensionFunc func(typ reflect.Type, field *reflect.StructField) ([]string, DecoderFunc)
type ExtractMany ¶
ExtractMany will extract several path ------------------------------------------- {"type":"XXX","a":"b",c:[1,3,5,8,{"d":"e","f":[23,"big"]}]}
func NewExtractMany ¶
func NewExtractMany(iter *Iterator, extracts ...*Extract) *ExtractMany
NewExtractMany constructor
type Iterator ¶
type Iterator struct { Error error // contains filtered or unexported fields }
Iterator is a fast and flexible JSON parser
func ParseBytes ¶
ParseBytes parses a json byte slice into an Iterator instance
func ParseString ¶
ParseString parses a json string into an Iterator instance
func (*Iterator) CurrentBuffer ¶
CurrentBuffer gets current buffer as string
func (*Iterator) ReadArrayCB ¶
func (*Iterator) ReadBase64 ¶
ReadBase64 reads a json object as Base64 in byte slice
func (*Iterator) ReadFloat32 ¶
func (*Iterator) ReadFloat64 ¶
func (*Iterator) ReadObject ¶
func (*Iterator) ReadObjectCB ¶
func (*Iterator) ReadStringAsSlice ¶
func (*Iterator) ReadUint16 ¶
func (*Iterator) ReadUint32 ¶
func (*Iterator) ReadUint64 ¶
func (*Iterator) ReadVal ¶
func (iter *Iterator) ReadVal(obj interface{})
Read converts an Iterator instance into go interface, same as json.Unmarshal
func (*Iterator) ResetBytes ¶
ResetBytes can reset an Iterator instance for another json byte slice
func (*Iterator) Skip ¶
func (iter *Iterator) Skip()
Skip skips a json object and positions to relatively the next json object
func (*Iterator) WhatIsNext ¶
WhatIsNext gets ValueType of relatively next json object
type KeyFloat64 ¶
type KeyFloat64 struct { Key IKey MayNull bool Float64 float64 // contains filtered or unexported fields }
KeyFloat64 -------------------------------------------------------
func (*KeyFloat64) MaybeNull ¶
func (kf *KeyFloat64) MaybeNull() bool
MaybeNull implement the KeyReader
type KeyInt64 ¶
type KeyInt64 struct { Key IKey MayNull bool Int64 int64 // contains filtered or unexported fields }
KeyInt64 ----------------------------------------------------------
type KeyReader ¶
type KeyReader interface { Read(iter *Iterator, key IKey) (bool, error) HasRead() bool MaybeNull() bool }
KeyReader represent a read to read the key
type KeyString ¶
type KeyString struct { Key IKey MayNull bool String string // contains filtered or unexported fields }
KeyString --------------------------------
type Path ¶
type Path []IKey
Path represent a path to extract var input2 = `{"a":["b",{"c","d"}]}` c: NewPath(Field("a"), Index(1))
type Stream ¶
func (*Stream) Buffered ¶
Buffered returns the number of bytes that have been written into the current buffer.
func (*Stream) Write ¶
Write writes the contents of p into the buffer. It returns the number of bytes written. If nn < len(p), it also returns an error explaining why the write is short.
func (*Stream) WriteArrayEnd ¶
func (stream *Stream) WriteArrayEnd()
func (*Stream) WriteArrayStart ¶
func (stream *Stream) WriteArrayStart()
func (*Stream) WriteEmptyArray ¶
func (stream *Stream) WriteEmptyArray()
func (*Stream) WriteEmptyObject ¶
func (stream *Stream) WriteEmptyObject()
func (*Stream) WriteFalse ¶
func (stream *Stream) WriteFalse()
func (*Stream) WriteFloat32 ¶
func (*Stream) WriteFloat64 ¶
func (*Stream) WriteInt16 ¶
func (*Stream) WriteInt32 ¶
func (*Stream) WriteInt64 ¶
func (*Stream) WriteObjectEnd ¶
func (stream *Stream) WriteObjectEnd()
func (*Stream) WriteObjectField ¶
func (*Stream) WriteObjectStart ¶
func (stream *Stream) WriteObjectStart()
func (*Stream) WriteString ¶
func (*Stream) WriteUint16 ¶
func (*Stream) WriteUint32 ¶
func (*Stream) WriteUint64 ¶
func (*Stream) WriteUint8 ¶
Source Files ¶
- feature_adapter.go
- feature_any.go
- feature_any_array.go
- feature_any_bool.go
- feature_any_float.go
- feature_any_int32.go
- feature_any_int64.go
- feature_any_invalid.go
- feature_any_nil.go
- feature_any_object.go
- feature_any_string.go
- feature_any_uint32.go
- feature_any_uint64.go
- feature_iter.go
- feature_iter_array.go
- feature_iter_float.go
- feature_iter_int.go
- feature_iter_object.go
- feature_iter_skip.go
- feature_iter_string.go
- feature_reflect.go
- feature_reflect_array.go
- feature_reflect_native.go
- feature_reflect_object.go
- feature_stream.go
- feature_stream_float.go
- feature_stream_int.go
- key.go
- key_extract.go
- key_extract_path.go
- key_reader.go