Decoder reads and decodes JSON values from an input stream.
Decoder provides identical APIs with json/stream Decoder (Token() and UseNumber() are in progress)
iter*Iterator
Buffered remaining buffer
Decode decode JSON into interface{}
DisallowUnknownFields causes 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.
More is there more?
UseNumber causes the Decoder to unmarshal a number into an interface{} as a
Number instead of as a float64.
func NewDecoder(reader io.Reader) *Decoder
func API.NewDecoder(reader io.Reader) *Decoder
CreateDecoder get decoder from map
CreateEncoder No-op
CreateMapKeyDecoder No-op
CreateMapKeyEncoder No-op
DecorateDecoder No-op
DecorateEncoder No-op
UpdateStructDescriptor No-op
T : Extension
DummyExtension embed this type get dummy implementation for all methods of Extension
CreateDecoder No-op
CreateEncoder No-op
CreateMapKeyDecoder No-op
CreateMapKeyEncoder No-op
DecorateDecoder No-op
DecorateEncoder No-op
UpdateStructDescriptor No-op
*T : Extension
Encoder same as json.Encoder
stream*Stream
Encode encode interface{} as JSON to io.Writer
SetEscapeHTML escape html by default, set to false to disable
SetIndent set the indention. Prefix is not supported
func NewEncoder(writer io.Writer) *Encoder
func API.NewEncoder(writer io.Writer) *Encoder
CreateDecoder No-op
CreateEncoder get encoder from map
CreateMapKeyDecoder No-op
CreateMapKeyEncoder No-op
DecorateDecoder No-op
DecorateEncoder No-op
UpdateStructDescriptor No-op
T : Extension
Float64 returns the number as a float64.
Int64 returns the number as an int64.
String returns the literal text of the number.
T : fmt.Stringer
T : context.stringer
T : gopkg.in/yaml.v2.jsonNumber
T : os/signal.stringer
T : runtime.stringer
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.
// open for customized encoder
Errorerrorbuf[]bytecfg*frozenConfigindentionintoutio.Writer
Available returns how many bytes are unused in the buffer.
Buffer if writer is nil, use this method to take the result
Buffered returns the number of bytes that have been written into the current buffer.
Flush writes any buffered data to the underlying io.Writer.
Pool returns a pool can provide more stream with same configuration
Reset reuse this stream instance by assign a new writer
SetBuffer allows to append to the internal buffer directly
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.
WriteArrayEnd write ] with possible indention
WriteArrayStart write [ with possible indention
WriteBool write true or false into stream
WriteEmptyArray write []
WriteEmptyObject write {}
WriteFalse write false to stream
WriteFloat32 write float32 to stream
WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
WriteFloat64 write float64 to stream
WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
WriteInt write int to stream
WriteInt16 write int16 to stream
WriteInt32 write int32 to stream
WriteInt64 write int64 to stream
WriteInt8 write int8 to stream
WriteMore write , with possible indention
WriteNil write null to stream
WriteObjectEnd write } with possible indention
WriteObjectField write "field": with possible indention
WriteObjectStart write { with possible indention
WriteRaw write string out without quotes, just like []byte
WriteString write string to stream without html escape
WriteStringWithHTMLEscaped write string to stream with html special characters escaped
WriteTrue write true to stream
WriteUint write uint to stream
WriteUint16 write uint16 to stream
WriteUint32 write uint32 to stream
WriteUint64 write uint64 to stream
WriteUint8 write uint8 to stream
WriteVal copy the go interface into underlying JSON, same as json.Marshal
WriteByte writes a single byte.
(*T) writeFiveBytes(c1 byte, c2 byte, c3 byte, c4 byte, c5 byte)(*T) writeFourBytes(c1 byte, c2 byte, c3 byte, c4 byte)(*T) writeIndention(delta int)(*T) writeThreeBytes(c1 byte, c2 byte, c3 byte)(*T) writeTwoBytes(c1 byte, c2 byte)
*T : io.Writer
func NewStream(cfg API, out io.Writer, bufSize int) *Stream
func API.BorrowStream(writer io.Writer) *Stream
func StreamPool.BorrowStream(writer io.Writer) *Stream
func Any.WriteTo(stream *Stream)
func API.ReturnStream(stream *Stream)
func (*OptionalEncoder).Encode(ptr unsafe.Pointer, stream *Stream)
func StreamPool.ReturnStream(stream *Stream)
func ValEncoder.Encode(ptr unsafe.Pointer, stream *Stream)
func writeStringSlowPath(stream *Stream, i int, s string, valLen int)
func writeStringSlowPathWithHTMLEscaped(stream *Stream, i int, s string, valLen int)
Get quick method to get value from deeply nested JSON structure
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
MarshalIndent same as json.MarshalIndent. Prefix is not supported.
MarshalToString convenient method to write as string instead of []byte
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
NewEncoder same as json.NewEncoder
NewIterator creates an empty Iterator instance
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.
Parse creates an Iterator instance from io.Reader
ParseBytes creates an Iterator instance from byte array
ParseString creates an Iterator instance from string
RegisterExtension register extension
RegisterFieldDecoder register TypeDecoder for a struct field
RegisterFieldDecoderFunc register TypeDecoder for a struct field with function
RegisterFieldEncoder register TypeEncoder for a struct field
RegisterFieldEncoderFunc register TypeEncoder for a struct field with encode/isEmpty function
RegisterTypeDecoder register TypeDecoder for a typ
RegisterTypeDecoderFunc register TypeDecoder for a type with function
RegisterTypeEncoder register TypeEncoder for a type
RegisterTypeEncoderFunc register TypeEncoder for a type with encode/isEmpty function
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
UnmarshalFromString is a convenient method to read from string instead of []byte
Valid reports whether data is a valid JSON encoding.
htmlSafeSet holds the value true if the ASCII character with the given
array position can be safely represented inside a JSON string, embedded
inside of HTML <script> tags, without any additional escaping.
All values are true except for the ASCII control characters (0-31), the
double quote ("), the backslash character ("\"), HTML opening and closing
tags ("<" and ">"), and the ampersand ("&").
safeSet holds the value true if the ASCII character with the given array
position can be represented inside a JSON string without any further
escaping.
All values are true except for the ASCII control characters (0-31), the
double quote ("), and the backslash character ("\").
The pages are generated with Goldsv0.3.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.