json
v1.7.0
Documentation
pkg.go.dev ↗Types
Encoder
type Encoder struct{}
Encoder.AppendArrayDelim
func (Encoder) AppendArrayDelim(dst []byte) []byte
AppendArrayDelim adds markers to indicate end of a particular array element.
Encoder.AppendArrayEnd
func (Encoder) AppendArrayEnd(dst []byte) []byte
AppendArrayEnd adds markers to indicate the end of an array.
Encoder.AppendArrayStart
func (Encoder) AppendArrayStart(dst []byte) []byte
AppendArrayStart adds markers to indicate the start of an array.
Encoder.AppendBeginMarker
func (Encoder) AppendBeginMarker(dst []byte) []byte
AppendBeginMarker inserts a map start into the dst byte array.
Encoder.AppendBool
func (Encoder) AppendBool(dst []byte, val bool) []byte
AppendBool converts the input bool to a string and appends the encoded string to the input byte slice.
Encoder.AppendBools
func (Encoder) AppendBools(dst []byte, vals []bool) []byte
AppendBools encodes the input bools to json and appends the encoded string list to the input byte slice.
Encoder.AppendBytes
func (Encoder) AppendBytes(dst, s []byte) []byte
AppendBytes is a mirror of appendString with []byte arg
Encoder.AppendDuration
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte
AppendDuration formats the input duration with the given unit & format and appends the encoded string to the input byte slice.
Encoder.AppendDurations
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte
AppendDurations formats the input durations with the given unit & format and appends the encoded string list to the input byte slice.
Encoder.AppendEndMarker
func (Encoder) AppendEndMarker(dst []byte) []byte
AppendEndMarker inserts a map end into the dst byte array.
Encoder.AppendError
func (e Encoder) AppendError(dst []byte, err error) []byte
AppendError encodes the error string to json and appends the encoded string to the input byte slice.
Encoder.AppendErrors
func (e Encoder) AppendErrors(dst []byte, errs []error) []byte
AppendErrors encodes the error strings to json and appends the encoded string list to the input byte slice.
Encoder.AppendFloat32
func (Encoder) AppendFloat32(dst []byte, val float32) []byte
AppendFloat32 converts the input float32 to a string and appends the encoded string to the input byte slice.
Encoder.AppendFloat64
func (Encoder) AppendFloat64(dst []byte, val float64) []byte
AppendFloat64 converts the input float64 to a string and appends the encoded string to the input byte slice.
Encoder.AppendFloats32
func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte
AppendFloats32 encodes the input float32s to json and appends the encoded string list to the input byte slice.
Encoder.AppendFloats64
func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte
AppendFloats64 encodes the input float64s to json and appends the encoded string list to the input byte slice.
Encoder.AppendHex
func (Encoder) AppendHex(dst, s []byte) []byte
AppendHex encodes the input bytes to a hex string and appends the encoded string to the input byte slice.
The operation loops though each byte and encodes it as hex using the hex lookup table.
Encoder.AppendIPAddr
func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte
AppendIPAddr adds IPv4 or IPv6 address to dst.
Encoder.AppendIPPrefix
func (e Encoder) AppendIPPrefix(dst []byte, pfx net.IPNet) []byte
AppendIPPrefix adds IPv4 or IPv6 Prefix (address & mask) to dst.
Encoder.AppendInt
func (Encoder) AppendInt(dst []byte, val int) []byte
AppendInt converts the input int to a string and appends the encoded string to the input byte slice.
Encoder.AppendInt16
func (Encoder) AppendInt16(dst []byte, val int16) []byte
AppendInt16 converts the input int16 to a string and appends the encoded string to the input byte slice.
Encoder.AppendInt32
func (Encoder) AppendInt32(dst []byte, val int32) []byte
AppendInt32 converts the input int32 to a string and appends the encoded string to the input byte slice.
Encoder.AppendInt64
func (Encoder) AppendInt64(dst []byte, val int64) []byte
AppendInt64 converts the input int64 to a string and appends the encoded string to the input byte slice.
Encoder.AppendInt8
func (Encoder) AppendInt8(dst []byte, val int8) []byte
AppendInt8 converts the input []int8 to a string and appends the encoded string to the input byte slice.
Encoder.AppendInterface
func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte
AppendInterface marshals the input interface to a string and appends the encoded string to the input byte slice.
Encoder.AppendInts
func (Encoder) AppendInts(dst []byte, vals []int) []byte
AppendInts encodes the input ints to json and appends the encoded string list to the input byte slice.
Encoder.AppendInts16
func (Encoder) AppendInts16(dst []byte, vals []int16) []byte
AppendInts16 encodes the input int16s to json and appends the encoded string list to the input byte slice.
Encoder.AppendInts32
func (Encoder) AppendInts32(dst []byte, vals []int32) []byte
AppendInts32 encodes the input int32s to json and appends the encoded string list to the input byte slice.
Encoder.AppendInts64
func (Encoder) AppendInts64(dst []byte, vals []int64) []byte
AppendInts64 encodes the input int64s to json and appends the encoded string list to the input byte slice.
Encoder.AppendInts8
func (Encoder) AppendInts8(dst []byte, vals []int8) []byte
AppendInts8 encodes the input int8s to json and appends the encoded string list to the input byte slice.
Encoder.AppendKey
func (e Encoder) AppendKey(dst []byte, key string) []byte
AppendKey appends a new key to the output JSON.
Encoder.AppendLineBreak
func (Encoder) AppendLineBreak(dst []byte) []byte
AppendLineBreak appends a line break.
Encoder.AppendMACAddr
func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte
AppendMACAddr adds MAC address to dst.
Encoder.AppendNil
func (Encoder) AppendNil(dst []byte) []byte
AppendNil inserts a 'Nil' object into the dst byte array.
Encoder.AppendObjectData
func (Encoder) AppendObjectData(dst []byte, o []byte) []byte
AppendObjectData takes in an object that is already in a byte array and adds it to the dst.
Encoder.AppendString
func (Encoder) AppendString(dst []byte, s string) []byte
AppendString encodes the input string to json and appends the encoded string to the input byte slice.
The operation loops though each byte in the string looking for characters that need json or utf8 encoding. If the string does not need encoding, then the string is appended in it's entirety to the byte slice. If we encounter a byte that does need encoding, switch up the operation and perform a byte-by-byte read-encode-append.
Encoder.AppendStrings
func (e Encoder) AppendStrings(dst []byte, vals []string) []byte
AppendStrings encodes the input strings to json and appends the encoded string list to the input byte slice.
Encoder.AppendTime
func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte
AppendTime formats the input time with the given format and appends the encoded string to the input byte slice.
Encoder.AppendTimes
func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte
AppendTimes converts the input times with the given format and appends the encoded string list to the input byte slice.
Encoder.AppendUint
func (Encoder) AppendUint(dst []byte, val uint) []byte
AppendUint converts the input uint to a string and appends the encoded string to the input byte slice.
Encoder.AppendUint16
func (Encoder) AppendUint16(dst []byte, val uint16) []byte
AppendUint16 converts the input uint16 to a string and appends the encoded string to the input byte slice.
Encoder.AppendUint32
func (Encoder) AppendUint32(dst []byte, val uint32) []byte
AppendUint32 converts the input uint32 to a string and appends the encoded string to the input byte slice.
Encoder.AppendUint64
func (Encoder) AppendUint64(dst []byte, val uint64) []byte
AppendUint64 converts the input uint64 to a string and appends the encoded string to the input byte slice.
Encoder.AppendUint8
func (Encoder) AppendUint8(dst []byte, val uint8) []byte
AppendUint8 converts the input uint8 to a string and appends the encoded string to the input byte slice.
Encoder.AppendUints
func (Encoder) AppendUints(dst []byte, vals []uint) []byte
AppendUints encodes the input uints to json and appends the encoded string list to the input byte slice.
Encoder.AppendUints16
func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte
AppendUints16 encodes the input uint16s to json and appends the encoded string list to the input byte slice.
Encoder.AppendUints32
func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte
AppendUints32 encodes the input uint32s to json and appends the encoded string list to the input byte slice.
Encoder.AppendUints64
func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte
AppendUints64 encodes the input uint64s to json and appends the encoded string list to the input byte slice.
Encoder.AppendUints8
func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte
AppendUints8 encodes the input uint8s to json and appends the encoded string list to the input byte slice.