package jx

Import Path
	github.com/go-faster/jx (on go.dev)

Dependency Relation
	imports 15 packages, and imported by 2 packages


Package-Level Type Names (total 12, in which 8 are exported)
/* sort exporteds by: | */
ArrIter is decoding array iterator. 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. 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. func Decode(reader io.Reader, bufSize int) *Decoder func DecodeBytes(input []byte) *Decoder func DecodeStr(input string) *Decoder func GetDecoder() *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. 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. Encoder : fmt.Stringer *Encoder : internal/bisect.Writer *Encoder : io.Closer *Encoder : io.WriteCloser *Encoder : io.Writer *Encoder : io.WriterTo 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 : fmt.Formatter Num : fmt.Stringer func (*Decoder).Num() (Num, error) func (*Decoder).NumAppend(v Num) (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
ObjIter is decoding object iterator. 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)
Raw json value. ( Raw) String() string Type of Raw json value. Raw : fmt.Stringer func (*Decoder).Raw() (Raw, error) func (*Decoder).RawAppend(buf Raw) (Raw, error) func (*Decoder).RawAppend(buf Raw) (Raw, error)
Type of json value. ( Type) String() string Type : fmt.Stringer func (*Decoder).Next() Type func Raw.Type() Type const Array const Bool const Invalid const Null const Number const Object const String
Writer writes json tokens to underlying buffer. Zero value is valid. // underlying buffer 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. Writer : fmt.Stringer *Writer : internal/bisect.Writer *Writer : io.Closer *Writer : io.WriteCloser *Writer : io.Writer *Writer : io.WriterTo func GetWriter() *Writer func PutWriter(e *Writer)
Package-Level Functions (total 29, in which 11 are exported)
Decode creates a Decoder that reads json from io.Reader.
DecodeBytes creates a Decoder that reads json from byte slice.
DecodeStr creates a Decoder that reads string as json.
GetDecoder gets *Decoder from pool.
GetEncoder returns *Encoder from pool.
GetWriter returns *Writer from pool.
NewStreamingEncoder creates new streaming encoder.
PutDecoder puts *Decoder into pool.
PutEncoder puts *Encoder to pool
PutWriter puts *Writer to pool
Valid reports whether data is valid json.
Package-Level Variables (total 17, none are exported)
Package-Level Constants (total 23, in which 7 are exported)
Array json value, like [1, 2, 3].
Bool json value, true or false.
Invalid json value.
Null json value.
Number json value, like 100 or 1.01.
Object json value, like {"foo": 1}.
String json value, like "foo".