json

package
v0.0.0-...-05bc493 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFloat

func AppendFloat(dst []byte, val float64, bitSize int) []byte

func AppendHex

func AppendHex(dst, s []byte) []byte

func AppendKey

func AppendKey(dst []byte, key string) []byte

func AppendMarshalled

func AppendMarshalled(dst []byte, v interface{}) []byte

func AppendMetricTimeMark

func AppendMetricTimeMark(buf []byte, reportedAt time.Time) []byte

func AppendOptQuotedString

func AppendOptQuotedString(dst []byte, s string) []byte

AppendOptQuotedString only adds quotes when escaped characters or spaces are present.

func AppendString

func 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.

func AppendStrings

func AppendStrings(dst []byte, vals []string) []byte

AppendStrings encodes the input strings to json and appends the encoded string list to the input byte slice.

func CutMetricTimeMarkAndEol

func CutMetricTimeMarkAndEol(dst *[]byte, eol []byte, now time.Time) (bool, time.Duration)

func EncoderManager

func EncoderManager() msgencoder.EncoderFactory

Types

type MetricTimeWriter

type MetricTimeWriter struct {
	Writer   io.Writer
	Eol      []byte
	ReportFn func(time.Duration)
	AppendFn func([]byte, time.Duration) []byte
}

func (MetricTimeWriter) Write

func (w MetricTimeWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL