go: github.com/json-iterator/go Index | Examples | Files | Directories

package jsoniter

import "github.com/json-iterator/go"

Package jsoniter implements encoding and decoding of JSON as defined in RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json. Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter and variable type declarations (if any). jsoniter interfaces gives 100% compatibility with code using standard lib.

"JSON and Go" (https://golang.org/doc/articles/json_and_go.html) gives a description of how Marshal/Unmarshal operate between arbitrary or predefined json objects and bytes, and it applies to jsoniter.Marshal/Unmarshal as well.

Besides, jsoniter.Iterator provides a different set of interfaces iterating given bytes/string/reader and yielding parsed elements one by one. This set of interfaces reads input as required and gives better performance.

Index

Examples

Package 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_number.go feature_any_object.go feature_any_string.go feature_any_uint32.go feature_any_uint64.go feature_config.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_skip_strict.go feature_iter_string.go feature_json_number.go feature_pool.go feature_reflect.go feature_reflect_array.go feature_reflect_extension.go feature_reflect_map.go feature_reflect_native.go feature_reflect_object.go feature_reflect_slice.go feature_reflect_struct_decoder.go feature_stream.go feature_stream_float.go feature_stream_int.go feature_stream_string.go jsoniter.go

Variables

var ConfigCompatibleWithStandardLibrary = Config{
    EscapeHTML:  true,
    SortMapKeys: true,
}.Froze()

ConfigCompatibleWithStandardLibrary tries to be 100% compatible with standard library behavior

var ConfigDefault = Config{
    EscapeHTML: true,
}.Froze()

ConfigDefault the default API

var ConfigFastest = Config{
    EscapeHTML:              false,
    MarshalFloatWith6Digits: true,
}.Froze()

ConfigFastest marshals float with only 6 digits precision

func CastJsonNumber Uses

func CastJsonNumber(val interface{}) (string, bool)

func Marshal Uses

func Marshal(v interface{}) ([]byte, error)

Marshal adapts to json/encoding Marshal API

Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API Refer to https://godoc.org/encoding/json#Marshal for more information

Code:

type ColorGroup struct {
    ID     int
    Name   string
    Colors []string
}
group := ColorGroup{
    ID:     1,
    Name:   "Reds",
    Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
}
b, err := Marshal(group)
if err != nil {
    fmt.Println("error:", err)
}
os.Stdout.Write(b)

Output:

{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}

func MarshalIndent Uses

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

MarshalIndent same as json.MarshalIndent. Prefix is not supported.

func MarshalToString Uses

func MarshalToString(v interface{}) (string, error)

MarshalToString convenient method to write as string instead of []byte

func RegisterExtension Uses

func RegisterExtension(extension Extension)

RegisterExtension register extension

func RegisterFieldDecoder Uses

func RegisterFieldDecoder(typ string, field string, decoder ValDecoder)

RegisterFieldDecoder register TypeDecoder for a struct field

func RegisterFieldDecoderFunc Uses

func RegisterFieldDecoderFunc(typ string, field string, fun DecoderFunc)

RegisterFieldDecoderFunc register TypeDecoder for a struct field with function

func RegisterFieldEncoder Uses

func RegisterFieldEncoder(typ string, field string, encoder ValEncoder)

RegisterFieldEncoder register TypeEncoder for a struct field

func RegisterFieldEncoderFunc Uses

func RegisterFieldEncoderFunc(typ string, field string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool)

RegisterFieldEncoderFunc register TypeEncoder for a struct field with encode/isEmpty function

func RegisterTypeDecoder Uses

func RegisterTypeDecoder(typ string, decoder ValDecoder)

RegisterTypeDecoder register TypeDecoder for a typ

func RegisterTypeDecoderFunc Uses

func RegisterTypeDecoderFunc(typ string, fun DecoderFunc)

RegisterTypeDecoderFunc register TypeDecoder for a type with function

func RegisterTypeEncoder Uses

func RegisterTypeEncoder(typ string, encoder ValEncoder)

RegisterTypeEncoder register TypeEncoder for a type

func RegisterTypeEncoderFunc Uses

func RegisterTypeEncoderFunc(typ string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool)

RegisterTypeEncoderFunc register TypeEncoder for a type with encode/isEmpty function

func Unmarshal Uses

func Unmarshal(data []byte, v interface{}) error

Unmarshal adapts to json/encoding Unmarshal API

Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. Refer to https://godoc.org/encoding/json#Unmarshal for more information

Code:

var jsonBlob = []byte(`[
		{"Name": "Platypus", "Order": "Monotremata"},
		{"Name": "Quoll",    "Order": "Dasyuromorphia"}
	]`)
type Animal struct {
    Name  string
    Order string
}
var animals []Animal
err := Unmarshal(jsonBlob, &animals)
if err != nil {
    fmt.Println("error:", err)
}
fmt.Printf("%+v", animals)

Output:

[{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]

func UnmarshalFromString Uses

func UnmarshalFromString(str string, v interface{}) error

UnmarshalFromString convenient method to read from string instead of []byte

func WriteToStream Uses

func WriteToStream(val interface{}, stream *Stream, encoder ValEncoder)

WriteToStream the default implementation for TypeEncoder method EncodeInterface

type API Uses

type API interface {
    IteratorPool
    StreamPool
    MarshalToString(v interface{}) (string, error)
    Marshal(v interface{}) ([]byte, error)
    MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
    UnmarshalFromString(str string, v interface{}) error
    Unmarshal(data []byte, v interface{}) error
    Get(data []byte, path ...interface{}) Any
    NewEncoder(writer io.Writer) *Encoder
    NewDecoder(reader io.Reader) *Decoder
}

API the public interface of this package. Primary Marshal and Unmarshal.

type Any Uses

type Any interface {
    LastError() error
    ValueType() ValueType
    MustBeValid() Any
    ToBool() bool
    ToInt() int
    ToInt32() int32
    ToInt64() int64
    ToUint() uint
    ToUint32() uint32
    ToUint64() uint64
    ToFloat32() float32
    ToFloat64() float64
    ToString() string
    ToVal(val interface{})
    Get(path ...interface{}) Any
    // TODO: add Set
    Size() int
    Keys() []string
    GetInterface() interface{}
    WriteTo(stream *Stream)
}

Any generic object representation. The lazy json implementation holds []byte and parse lazily.

func Get Uses

func Get(data []byte, path ...interface{}) Any

Get quick method to get value from deeply nested JSON structure

Code:

val := []byte(`{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}`)
fmt.Printf(Get(val, "Colors", 0).ToString())

Output:

Crimson

func Wrap Uses

func Wrap(val interface{}) Any

Wrap turn a go object into Any interface

func WrapFloat64 Uses

func WrapFloat64(val float64) Any

WrapFloat64 turn float64 into Any interface

func WrapInt32 Uses

func WrapInt32(val int32) Any

WrapInt32 turn int32 into Any interface

func WrapInt64 Uses

func WrapInt64(val int64) Any

WrapInt64 turn int64 into Any interface

func WrapString Uses

func WrapString(val string) Any

WrapString turn string into Any interface

func WrapUint32 Uses

func WrapUint32(val uint32) Any

WrapUint32 turn uint32 into Any interface

func WrapUint64 Uses

func WrapUint64(val uint64) Any

WrapUint64 turn uint64 into Any interface

type Binding Uses

type Binding struct {
    Field     *reflect.StructField
    FromNames []string
    ToNames   []string
    Encoder   ValEncoder
    Decoder   ValDecoder
    // contains filtered or unexported fields
}

Binding describe how should we encode/decode the struct field

type Config Uses

type Config struct {
    IndentionStep           int
    MarshalFloatWith6Digits bool
    EscapeHTML              bool
    SortMapKeys             bool
    UseNumber               bool
    TagKey                  string
}

Config customize how the API should behave. The API is created from Config by Froze.

func (Config) Froze Uses

func (cfg Config) Froze() API

Froze forge API from config

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields
}

Decoder reads and decodes JSON values from an input stream. Decoder provides identical APIs with json/stream Decoder (Token() and UseNumber() are in progress)

func NewDecoder Uses

func NewDecoder(reader io.Reader) *Decoder

NewDecoder adapts to json/stream NewDecoder API.

NewDecoder returns a new decoder that reads from r.

Instead of a json/encoding Decoder, an Decoder is returned Refer to https://godoc.org/encoding/json#NewDecoder for more information

func (*Decoder) Buffered Uses

func (adapter *Decoder) Buffered() io.Reader

Buffered remaining buffer

func (*Decoder) Decode Uses

func (adapter *Decoder) Decode(obj interface{}) error

Decode decode JSON into interface{}

func (*Decoder) More Uses

func (adapter *Decoder) More() bool

More is there more?

func (*Decoder) UseNumber Uses

func (adapter *Decoder) UseNumber()

UseNumber for number JSON element, use float64 or json.NumberValue (alias of string)

type DecoderFunc Uses

type DecoderFunc func(ptr unsafe.Pointer, iter *Iterator)

DecoderFunc the function form of TypeDecoder

type DummyExtension Uses

type DummyExtension struct {
}

DummyExtension embed this type get dummy implementation for all methods of Extension

func (*DummyExtension) CreateDecoder Uses

func (extension *DummyExtension) CreateDecoder(typ reflect.Type) ValDecoder

CreateDecoder No-op

func (*DummyExtension) CreateEncoder Uses

func (extension *DummyExtension) CreateEncoder(typ reflect.Type) ValEncoder

CreateEncoder No-op

func (*DummyExtension) DecorateDecoder Uses

func (extension *DummyExtension) DecorateDecoder(typ reflect.Type, decoder ValDecoder) ValDecoder

DecorateDecoder No-op

func (*DummyExtension) DecorateEncoder Uses

func (extension *DummyExtension) DecorateEncoder(typ reflect.Type, encoder ValEncoder) ValEncoder

DecorateEncoder No-op

func (*DummyExtension) UpdateStructDescriptor Uses

func (extension *DummyExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor)

UpdateStructDescriptor No-op

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields
}

Encoder same as json.Encoder

func NewEncoder Uses

func NewEncoder(writer io.Writer) *Encoder

NewEncoder same as json.NewEncoder

func (*Encoder) Encode Uses

func (adapter *Encoder) Encode(val interface{}) error

Encode encode interface{} as JSON to io.Writer

func (*Encoder) SetEscapeHTML Uses

func (adapter *Encoder) SetEscapeHTML(escapeHTML bool)

SetEscapeHTML escape html by default, set to false to disable

func (*Encoder) SetIndent Uses

func (adapter *Encoder) SetIndent(prefix, indent string)

SetIndent set the indention. Prefix is not supported

type EncoderFunc Uses

type EncoderFunc func(ptr unsafe.Pointer, stream *Stream)

EncoderFunc the function form of TypeEncoder

type Extension Uses

type Extension interface {
    UpdateStructDescriptor(structDescriptor *StructDescriptor)
    CreateDecoder(typ reflect.Type) ValDecoder
    CreateEncoder(typ reflect.Type) ValEncoder
    DecorateDecoder(typ reflect.Type, decoder ValDecoder) ValDecoder
    DecorateEncoder(typ reflect.Type, encoder ValEncoder) ValEncoder
}

Extension the one for all SPI. Customize encoding/decoding by specifying alternate encoder/decoder. Can also rename fields by UpdateStructDescriptor.

type Iterator Uses

type Iterator struct {
    Error error
    // contains filtered or unexported fields
}

Iterator is a io.Reader like object, with JSON specific read functions. Error is not returned as return value, but stored as Error member on this iterator instance.

func NewIterator Uses

func NewIterator(cfg API) *Iterator

NewIterator creates an empty Iterator instance

func Parse Uses

func Parse(cfg API, reader io.Reader, bufSize int) *Iterator

Parse creates an Iterator instance from io.Reader

func ParseBytes Uses

func ParseBytes(cfg API, input []byte) *Iterator

ParseBytes creates an Iterator instance from byte array

func ParseString Uses

func ParseString(cfg API, input string) *Iterator

ParseString creates an Iterator instance from string

func (*Iterator) CurrentBuffer Uses

func (iter *Iterator) CurrentBuffer() string

CurrentBuffer gets current buffer as string for debugging purpose

func (*Iterator) Pool Uses

func (iter *Iterator) Pool() IteratorPool

Pool returns a pool can provide more iterator with same configuration

func (*Iterator) Read Uses

func (iter *Iterator) Read() interface{}

Read read the next JSON element as generic interface{}.

func (*Iterator) ReadAny Uses

func (iter *Iterator) ReadAny() Any

ReadAny read next JSON element as an Any object. It is a better json.RawMessage.

func (*Iterator) ReadArray Uses

func (iter *Iterator) ReadArray() (ret bool)

ReadArray read array element, tells if the array has more element to read.

func (*Iterator) ReadArrayCB Uses

func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool)

ReadArrayCB read array with callback

func (*Iterator) ReadBigFloat Uses

func (iter *Iterator) ReadBigFloat() (ret *big.Float)

ReadBigFloat read big.Float

func (*Iterator) ReadBigInt Uses

func (iter *Iterator) ReadBigInt() (ret *big.Int)

ReadBigInt read big.Int

func (*Iterator) ReadBool Uses

func (iter *Iterator) ReadBool() (ret bool)

ReadBool reads a json object as BoolValue

func (*Iterator) ReadFloat32 Uses

func (iter *Iterator) ReadFloat32() (ret float32)

ReadFloat32 read float32

func (*Iterator) ReadFloat64 Uses

func (iter *Iterator) ReadFloat64() (ret float64)

ReadFloat64 read float64

func (*Iterator) ReadInt Uses

func (iter *Iterator) ReadInt() int

ReadInt read int

func (*Iterator) ReadInt16 Uses

func (iter *Iterator) ReadInt16() (ret int16)

ReadInt16 read int16

func (*Iterator) ReadInt32 Uses

func (iter *Iterator) ReadInt32() (ret int32)

ReadInt32 read int32

func (*Iterator) ReadInt64 Uses

func (iter *Iterator) ReadInt64() (ret int64)

ReadInt64 read int64

func (*Iterator) ReadInt8 Uses

func (iter *Iterator) ReadInt8() (ret int8)

ReadInt8 read int8

func (*Iterator) ReadMapCB Uses

func (iter *Iterator) ReadMapCB(callback func(*Iterator, string) bool) bool

ReadMapCB read map with callback, the key can be any string

func (*Iterator) ReadNil Uses

func (iter *Iterator) ReadNil() (ret bool)

ReadNil reads a json object as nil and returns whether it's a nil or not

func (*Iterator) ReadObject Uses

func (iter *Iterator) ReadObject() (ret string)

ReadObject read one field from object. If object ended, returns empty string. Otherwise, returns the field name.

func (*Iterator) ReadObjectCB Uses

func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool

ReadObjectCB read object with callback, the key is ascii only and field name not copied

func (*Iterator) ReadString Uses

func (iter *Iterator) ReadString() (ret string)

ReadString read string from iterator

func (*Iterator) ReadStringAsSlice Uses

func (iter *Iterator) ReadStringAsSlice() (ret []byte)

ReadStringAsSlice read string from iterator without copying into string form. The []byte can not be kept, as it will change after next iterator call.

func (*Iterator) ReadUint Uses

func (iter *Iterator) ReadUint() uint

ReadUint read uint

func (*Iterator) ReadUint16 Uses

func (iter *Iterator) ReadUint16() (ret uint16)

ReadUint16 read uint16

func (*Iterator) ReadUint32 Uses

func (iter *Iterator) ReadUint32() (ret uint32)

ReadUint32 read uint32

func (*Iterator) ReadUint64 Uses

func (iter *Iterator) ReadUint64() uint64

ReadUint64 read uint64

func (*Iterator) ReadUint8 Uses

func (iter *Iterator) ReadUint8() (ret uint8)

ReadUint8 read uint8

func (*Iterator) ReadVal Uses

func (iter *Iterator) ReadVal(obj interface{})

ReadVal copy the underlying JSON into go interface, same as json.Unmarshal

func (*Iterator) ReportError Uses

func (iter *Iterator) ReportError(operation string, msg string)

ReportError record a error in iterator instance with current position.

func (*Iterator) Reset Uses

func (iter *Iterator) Reset(reader io.Reader) *Iterator

Reset reuse iterator instance by specifying another reader

func (*Iterator) ResetBytes Uses

func (iter *Iterator) ResetBytes(input []byte) *Iterator

ResetBytes reuse iterator instance by specifying another byte array as input

func (*Iterator) Skip Uses

func (iter *Iterator) Skip()

Skip skips a json object and positions to relatively the next json object

func (*Iterator) SkipAndReturnBytes Uses

func (iter *Iterator) SkipAndReturnBytes() []byte

SkipAndReturnBytes skip next JSON element, and return its content as []byte. The []byte can be kept, it is a copy of data.

func (*Iterator) WhatIsNext Uses

func (iter *Iterator) WhatIsNext() ValueType

WhatIsNext gets ValueType of relatively next json element

type IteratorPool Uses

type IteratorPool interface {
    BorrowIterator(data []byte) *Iterator
    ReturnIterator(iter *Iterator)
}

IteratorPool a thread safe pool of iterators with same configuration

type Number Uses

type Number string

type RawMessage Uses

type RawMessage []byte

RawMessage to make replace json with jsoniter

type Stream Uses

type Stream struct {
    Error error
    // contains filtered or unexported fields
}

Stream is a io.Writer like object, with JSON specific write functions. Error is not returned as return value, but stored as Error member on this stream instance.

func NewStream Uses

func NewStream(cfg API, out io.Writer, bufSize int) *Stream

NewStream create new stream instance. cfg can be jsoniter.ConfigDefault. out can be nil if write to internal buffer. bufSize is the initial size for the internal buffer in bytes.

func (*Stream) Available Uses

func (stream *Stream) Available() int

Available returns how many bytes are unused in the buffer.

func (*Stream) Buffer Uses

func (stream *Stream) Buffer() []byte

Buffer if writer is nil, use this method to take the result

func (*Stream) Buffered Uses

func (stream *Stream) Buffered() int

Buffered returns the number of bytes that have been written into the current buffer.

func (*Stream) Flush Uses

func (stream *Stream) Flush() error

Flush writes any buffered data to the underlying io.Writer.

func (*Stream) Pool Uses

func (stream *Stream) Pool() StreamPool

Pool returns a pool can provide more stream with same configuration

func (*Stream) Reset Uses

func (stream *Stream) Reset(out io.Writer)

Reset reuse this stream instance by assign a new writer

func (*Stream) Write Uses

func (stream *Stream) Write(p []byte) (nn int, err error)

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 Uses

func (stream *Stream) WriteArrayEnd()

WriteArrayEnd write ] with possible indention

func (*Stream) WriteArrayStart Uses

func (stream *Stream) WriteArrayStart()

WriteArrayStart write [ with possible indention

func (*Stream) WriteBool Uses

func (stream *Stream) WriteBool(val bool)

WriteBool write true or false into stream

func (*Stream) WriteEmptyArray Uses

func (stream *Stream) WriteEmptyArray()

WriteEmptyArray write []

func (*Stream) WriteEmptyObject Uses

func (stream *Stream) WriteEmptyObject()

WriteEmptyObject write {}

func (*Stream) WriteFalse Uses

func (stream *Stream) WriteFalse()

WriteFalse write false to stream

func (*Stream) WriteFloat32 Uses

func (stream *Stream) WriteFloat32(val float32)

WriteFloat32 write float32 to stream

func (*Stream) WriteFloat32Lossy Uses

func (stream *Stream) WriteFloat32Lossy(val float32)

WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster

func (*Stream) WriteFloat64 Uses

func (stream *Stream) WriteFloat64(val float64)

WriteFloat64 write float64 to stream

func (*Stream) WriteFloat64Lossy Uses

func (stream *Stream) WriteFloat64Lossy(val float64)

WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster

func (*Stream) WriteInt Uses

func (stream *Stream) WriteInt(val int)

WriteInt write int to stream

func (*Stream) WriteInt16 Uses

func (stream *Stream) WriteInt16(nval int16)

WriteInt16 write int16 to stream

func (*Stream) WriteInt32 Uses

func (stream *Stream) WriteInt32(nval int32)

WriteInt32 write int32 to stream

func (*Stream) WriteInt64 Uses

func (stream *Stream) WriteInt64(nval int64)

WriteInt64 write int64 to stream

func (*Stream) WriteInt8 Uses

func (stream *Stream) WriteInt8(nval int8)

WriteInt8 write int8 to stream

func (*Stream) WriteMore Uses

func (stream *Stream) WriteMore()

WriteMore write , with possible indention

func (*Stream) WriteNil Uses

func (stream *Stream) WriteNil()

WriteNil write null to stream

func (*Stream) WriteObjectEnd Uses

func (stream *Stream) WriteObjectEnd()

WriteObjectEnd write } with possible indention

func (*Stream) WriteObjectField Uses

func (stream *Stream) WriteObjectField(field string)

WriteObjectField write "field": with possible indention

func (*Stream) WriteObjectStart Uses

func (stream *Stream) WriteObjectStart()

WriteObjectStart write { with possible indention

func (*Stream) WriteRaw Uses

func (stream *Stream) WriteRaw(s string)

WriteRaw write string out without quotes, just like []byte

func (*Stream) WriteString Uses

func (stream *Stream) WriteString(s string)

WriteString write string to stream without html escape

func (*Stream) WriteStringWithHTMLEscaped Uses

func (stream *Stream) WriteStringWithHTMLEscaped(s string)

WriteStringWithHTMLEscaped write string to stream with html special characters escaped

func (*Stream) WriteTrue Uses

func (stream *Stream) WriteTrue()

WriteTrue write true to stream

func (*Stream) WriteUint Uses

func (stream *Stream) WriteUint(val uint)

WriteUint write uint to stream

func (*Stream) WriteUint16 Uses

func (stream *Stream) WriteUint16(val uint16)

WriteUint16 write uint16 to stream

func (*Stream) WriteUint32 Uses

func (stream *Stream) WriteUint32(val uint32)

WriteUint32 write uint32 to stream

func (*Stream) WriteUint64 Uses

func (stream *Stream) WriteUint64(val uint64)

WriteUint64 write uint64 to stream

func (*Stream) WriteUint8 Uses

func (stream *Stream) WriteUint8(val uint8)

WriteUint8 write uint8 to stream

func (*Stream) WriteVal Uses

func (stream *Stream) WriteVal(val interface{})

WriteVal copy the go interface into underlying JSON, same as json.Marshal

type StreamPool Uses

type StreamPool interface {
    BorrowStream(writer io.Writer) *Stream
    ReturnStream(stream *Stream)
}

StreamPool a thread safe pool of streams with same configuration

type StructDescriptor Uses

type StructDescriptor struct {
    Type   reflect.Type
    Fields []*Binding
    // contains filtered or unexported fields
}

StructDescriptor describe how should we encode/decode the struct

func (*StructDescriptor) GetField Uses

func (structDescriptor *StructDescriptor) GetField(fieldName string) *Binding

GetField get one field from the descriptor by its name. Can not use map here to keep field orders.

type ValDecoder Uses

type ValDecoder interface {
    Decode(ptr unsafe.Pointer, iter *Iterator)
}

ValDecoder is an internal type registered to cache as needed. Don't confuse jsoniter.ValDecoder with json.Decoder. For json.Decoder's adapter, refer to jsoniter.AdapterDecoder(todo link).

Reflection on type to create decoders, which is then cached Reflection on value is avoided as we can, as the reflect.Value itself will allocate, with following exceptions 1. create instance of new value, for example *int will need a int to be allocated 2. append to slice, if the existing cap is not enough, allocate will be done using Reflect.New 3. assignment to map, both key and value will be reflect.Value For a simple struct binding, it will be reflect.Value free and allocation free

type ValEncoder Uses

type ValEncoder interface {
    IsEmpty(ptr unsafe.Pointer) bool
    Encode(ptr unsafe.Pointer, stream *Stream)
    EncodeInterface(val interface{}, stream *Stream)
}

ValEncoder is an internal type registered to cache as needed. Don't confuse jsoniter.ValEncoder with json.Encoder. For json.Encoder's adapter, refer to jsoniter.AdapterEncoder(todo godoc link).

type ValueType Uses

type ValueType int

ValueType the type for JSON element

const (
    // InvalidValue invalid JSON element
    InvalidValue ValueType = iota
    // StringValue JSON element "string"
    StringValue
    // NumberValue JSON element 100 or 0.10
    NumberValue
    // NilValue JSON element null
    NilValue
    // BoolValue JSON element true or false
    BoolValue
    // ArrayValue JSON element []
    ArrayValue
    // ObjectValue JSON element {}
    ObjectValue
)

Directories

PathSynopsis
extra
output_tests
output_tests/caseless_unmarshal
output_tests/partial_unmarshal

Package jsoniter imports 19 packages (graph) and is imported by 9 packages. Updated 2017-08-22. Refresh now. Tools for package owners.