Package-Level Type Names (total 12, in which 8 are exported)
/* sort exporteds by: | */
ArrIter is decoding array iterator.closedboolcommaboold*Decodererrerror Err returns the error, if any, that was encountered during iteration. Next consumes element and returns false, if there is no elements anymore.
func (*Decoder).ArrIter() (ArrIter, error)
Decoder decodes json.
Can decode from io.Reader or byte slice directly. buf is current buffer.
Contains full json if reader is nil or used as a read buffer
otherwise.depthint // offset in buf to start of current json streamreaderio.Reader // for reader, offset in stream to start of current buf contents // offset in buf to end of current json stream Arr decodes array and invokes callback on each array element. ArrIter creates new array iterator. Base64 decodes base64 encoded data from string.
Same as encoding/json, base64.StdEncoding or RFC 4648. Base64Append appends base64 encoded data from string.
Same as encoding/json, base64.StdEncoding or RFC 4648. BigFloat read big.Float BigInt read big.Int Bool reads a json object as Bool Capture calls f and then rolls back to state before call. Elem skips to the start of next array element, returning true boolean
if element exists.
Can be called before or in Array. Float32 reads float32 value. Float64 read float64 Int reads int. Int16 reads int16. Int32 reads int32. Int64 reads int64. Int8 reads int8. Next gets Type of relatively next json element Null reads a json object as null and
returns whether it's a null or not. Num decodes number.
Do not retain returned value, it references underlying buffer. NumAppend appends number. Obj reads json object, calling f on each field.
Use ObjBytes to reduce heap allocations for keys. ObjBytes calls f for every key in object, using byte slice as key.
The key value is valid only until f is not returned. ObjIter creates new object iterator. Raw is like Skip(), but saves and returns skipped value as raw json.
Do not retain returned value, it references underlying buffer. RawAppend is Raw that appends saved raw json value to buf. Reset resets reader and underlying state, next reads will use provided io.Reader. ResetBytes resets underlying state, next reads will use provided buffer. Skip skips a json object and positions to relatively the next json object. Str reads string. StrAppend reads string and appends it to byte slice. StrBytes returns string value as sub-slice of internal buffer.
Bytes are valid only until next call to any Decoder method. UInt reads uint. UInt16 reads uint16. UInt32 reads uint32. UInt64 reads uint64. UInt8 reads uint8. Validate consumes all input, validating that input is a json object
without any trialing data.(*Decoder) byte() (byte, error)(*Decoder) consume(c byte) (err error)(*Decoder) decDepth() error(*Decoder) escapedChar(v value, c byte) (value, error)(*Decoder) float32Slow() (float32, error)(*Decoder) float64Slow() (float64, error)(*Decoder) floatSlow(size int) (float64, error)(*Decoder) incDepth() error(*Decoder) int(size int) (int, error) more is next but io.EOF is unexpected. next reads next non-whitespace token or error. num decodes number.(*Decoder) number() ([]byte, error)(*Decoder) numberAppend(b []byte) ([]byte, error)(*Decoder) offset() int peek returns next byte without advancing.(*Decoder) positiveFloat32() (float32, error)(*Decoder) positiveFloat64() (float64, error)(*Decoder) read() error(*Decoder) readAtLeast(min int) error(*Decoder) readExact4(b *[4]byte) error(*Decoder) readU4() (v rune, _ error)(*Decoder) readUInt16(c byte) (uint16, error)(*Decoder) readUInt32(c byte) (uint32, error)(*Decoder) readUInt64(c byte) (uint64, error)(*Decoder) readUInt8(c byte) (uint8, error) skipArr reads JSON array.
Assumes first bracket was consumed. skipNumber reads one JSON number.
Assumes d.buf is not empty. skipObj reads JSON object.
Assumes first bracket was consumed. skipSpace skips space characters.
Returns io.ErrUnexpectedEOF if got io.EOF. skipStr reads one JSON string.
Assumes first quote was consumed.(*Decoder) str(v value) (value, error)(*Decoder) strSlow(v value) (value, error)(*Decoder) uint(size int) (uint, error)(*Decoder) unread()
func Decode(reader io.Reader, bufSize int) *Decoder
func DecodeBytes(input []byte) *Decoder
func DecodeStr(input string) *Decoder
func GetDecoder() *Decoder
func Num.dec() Decoder
func PutDecoder(d *Decoder)
func github.com/gotd/td/internal/crypto.(*AuthKey).DecodeJSON(d *Decoder) error
Encoder encodes json to underlying buffer.
Zero value is valid. first handles state for comma and indentation writing.
New Object or Array appends new level to this slice, and
last element of this slice denotes whether first element was written.
We write commas only before non-first element of Array or Object.
See comma, begin, end and FieldStart for implementation details.
Note: probably, this can be optimized as bit set to ease memory
consumption.
See https://yourbasic.org/algorithms/your-basic-int/#simple-sets // count of spaces for single indentation level // underlying writer Arr writes start of array, invokes callback and writes end of array.
If callback is nil, writes empty array. ArrEmpty writes empty array. ArrEnd writes end of array, performing indentation if needed.
Use Arr as convenience helper for writing arrays. ArrStart writes start of array, performing indentation if needed.
Use Arr as convenience helper for writing arrays. Base64 encodes data as standard base64 encoded string.
Same as encoding/json, base64.StdEncoding or RFC 4648. Bool encodes boolean. ByteStr encodes byte slice without html escaping.
Use ByteStrEscape to escape html, this is default for encoding/json and
should be used by default for untrusted strings. ByteStrEscape encodes string with html special characters escaping. Bytes returns underlying buffer. Close flushes underlying buffer to writer in streaming mode.
Otherwise, it does nothing. Field encodes field start and then invokes callback.
Has ~5ns overhead over FieldStart. FieldStart encodes field name and writes colon.
For non-zero indentation also writes single space after colon.
Use Field as convenience helper for encoding fields. Float32 encodes float32.
NB: Infinities and NaN are represented as null. Float64 encodes float64.
NB: Infinities and NaN are represented as null. Grow grows the underlying buffer Int encodes int. Int16 encodes int16. Int32 encodes int32. Int64 encodes int64. Int8 encodes int8. Null writes null. Num encodes number. Obj writes start of object, invokes callback and writes end of object.
If callback is nil, writes empty object. ObjEmpty writes empty object. ObjEnd writes end of object token, performing indentation if needed.
Use Obj as convenience helper for writing objects. ObjStart writes object start, performing indentation if needed.
Use Obj as convenience helper for writing objects. Raw writes byte slice as raw json. RawStr writes string as raw json. Reset resets underlying buffer.
If e is in streaming mode, it is reset to non-streaming mode. ResetWriter resets underlying buffer and sets output writer. SetBytes sets underlying buffer. SetIdent sets length of single indentation step. Str encodes string without html escaping.
Use StrEscape to escape html, this is default for encoding/json and
should be used by default for untrusted strings. StrEscape encodes string with html special characters escaping. String returns string of underlying buffer. UInt encodes uint. UInt16 encodes uint16. UInt32 encodes uint32. UInt64 encodes uint64. UInt8 encodes uint8. Write implements io.Writer. WriteTo implements io.WriterTo. begin should be called before new Array or Object. byte writes a single byte. comma should be called before any new value.(*Encoder) current() int end should be called after Array or Object.(*Encoder) writeIndent() (fail bool)
Encoder : fmt.Stringer
*Encoder : internal/bisect.Writer
*Encoder : io.Closer
*Encoder : io.WriteCloser
*Encoder : io.Writer
*Encoder : io.WriterTo
Encoder : context.stringer
*Encoder : crypto/tls.transcriptHash
Encoder : runtime.stringer
func GetEncoder() *Encoder
func NewStreamingEncoder(w io.Writer, bufSize int) *Encoder
func PutEncoder(e *Encoder)
func github.com/gotd/td/internal/crypto.AuthKey.EncodeJSON(e *Encoder) error
Num represents number, which can be raw json number or number string.
Same as Raw, but with number invariants.
Examples:
123.45 // Str: false, IsInt: false
"123.45" // Str: true, IsInt: false
"12345" // Str: true, IsInt: true
12345 // Str: false, IsInt: true Equal reports whether numbers are strictly equal, including their formats. Float64 decodes number as 64-bit floating point. Format implements fmt.Formatter. Int64 decodes number as a signed 64-bit integer.
Works on floats with zero fractional part. IsInt reports whether number is integer. Negative reports whether number is negative. Positive reports whether number is positive. Sign reports sign of number.
0 is zero, 1 is positive, -1 is negative. Str reports whether Num is string number.( Num) String() string Uint64 decodes number as an unsigned 64-bit integer.
Works on floats with zero fractional part. Zero reports whether number is zero.( Num) dec() Decoder( Num) floatAsInt() (dotIdx int, _ error)
Num : fmt.Formatter
Num : fmt.Stringer
Num : context.stringer
Num : runtime.stringer
func (*Decoder).Num() (Num, error)
func (*Decoder).NumAppend(v Num) (Num, error)
func (*Decoder).num(v Num, forceAppend bool) (Num, error)
func (*Decoder).NumAppend(v Num) (Num, error)
func (*Encoder).Num(v Num) bool
func Num.Equal(v Num) bool
func (*Writer).Num(v Num) bool
func (*Decoder).num(v Num, forceAppend bool) (Num, error)
ObjIter is decoding object iterator.closedboolcommaboold*DecodererrerrorisBufferboolkey[]byte Err returns the error, if any, that was encountered during iteration. Key returns current key.
Key call must be preceded by a call to Next. Next consumes element and returns false, if there is no elements anymore.
func (*Decoder).ObjIter() (ObjIter, error)
Writer writes json tokens to underlying buffer.
Zero value is valid. // underlying bufferstream*streamState ArrEnd writes end of array. ArrStart writes start of array. Base64 encodes data as standard base64 encoded string.
Same as encoding/json, base64.StdEncoding or RFC 4648. Bool encodes boolean. ByteStr encodes string without html escaping.
Use ByteStrEscape to escape html, this is default for encoding/json and
should be used by default for untrusted strings. ByteStrEscape encodes string with html special characters escaping. Close flushes underlying buffer to writer in streaming mode.
Otherwise, it does nothing. Comma writes comma. False writes false. FieldStart encodes field name and writes colon. Float writes float value to buffer. Float32 encodes float32.
NB: Infinities and NaN are represented as null. Float64 encodes float64.
NB: Infinities and NaN are represented as null. Grow grows the underlying buffer.
Calls (*bytes.Buffer).Grow(n int) on w.Buf. Int encodes int. Int16 encodes int16. Int32 encodes int32. Int64 encodes int64. Int8 encodes int8. Null writes null. Num encodes number. ObjEnd writes end of object token. ObjStart writes object start. Raw writes byte slice as raw json. RawStr writes string as raw json. Reset resets underlying buffer.
If w is in streaming mode, it is reset to non-streaming mode. ResetWriter resets underlying buffer and sets output writer. Str encodes string without html escaping.
Use StrEscape to escape html, this is default for encoding/json and
should be used by default for untrusted strings. StrEscape encodes string with html special characters escaping. String returns string of underlying buffer. True writes true. UInt encodes uint. UInt16 encodes uint16. UInt32 encodes uint32. UInt64 encodes uint64. UInt8 encodes uint8. Write implements io.Writer. WriteTo implements io.WriterTo. byte writes a single byte.(*Writer) rawStr(v string) bool(*Writer) twoBytes(c1, c2 byte) bool
Writer : fmt.Stringer
*Writer : internal/bisect.Writer
*Writer : io.Closer
*Writer : io.WriteCloser
*Writer : io.Writer
*Writer : io.WriterTo
Writer : context.stringer
*Writer : crypto/tls.transcriptHash
Writer : runtime.stringer
func GetWriter() *Writer
func PutWriter(e *Writer)
func strEscape[S](w *Writer, v S) (fail bool)
func strEscapeSlow[S](w *Writer, i int, v S, valLen int) (fail bool)
func strSlow[S](w *Writer, v S) (fail bool)
func writeBuf(w *Writer, v uint32) bool
func writeFirstBuf(w *Writer, v uint32) bool
func writeStr[S](w *Writer, v S) (fail bool)
func writeStreamBytes(w *Writer, s ...byte) bool
func writeStreamByteseq[S](w *Writer, s S) bool
func writeStreamByteseqSlow[S](w *Writer, s S) bool
internal buffer, may be reference to *Decoder.buf. if true, buf is reference to *Decoder.buf.origio.Reader(*rawReader) Read(p []byte) (n int, err error)
*rawReader : io.Reader
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.6.7. (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.