internal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttributes

func AddAttributes(w *JSONFieldsWriter, attrs map[string]interface{})

AddAttributes writes the attributes to the fields writer.

func Compress

func Compress(b []byte) (*bytes.Buffer, error)

Compress gzips the given input. For better performance use CompressWithWriter with a pooled gzip.Writer.

func CompressWithWriter added in v0.5.2

func CompressWithWriter(b []byte, w *gzip.Writer) error

CompressWithWriter gzips the given input using a specific writer.

func MarshalAttributes

func MarshalAttributes(ats map[string]interface{}) []byte

MarshalAttributes turns attributes into JSON.

func MarshalOrderedAttributes

func MarshalOrderedAttributes(attrs map[string]interface{}) []byte

MarshalOrderedAttributes marshals the given attributes into JSON in alphabetical order.

func Uncompress

func Uncompress(b []byte) ([]byte, error)

Uncompress un-gzips the given input.

Types

type Attributes

type Attributes map[string]interface{}

Attributes is used for marshalling attributes to JSON.

func (Attributes) WriteJSON

func (attrs Attributes) WriteJSON(buf *bytes.Buffer)

WriteJSON writes the attributes in JSON.

type JSONFieldsWriter

type JSONFieldsWriter struct {
	Buf *bytes.Buffer
	// contains filtered or unexported fields
}

JSONFieldsWriter helps write JSON objects to a buffer.

func (*JSONFieldsWriter) AddKey

func (w *JSONFieldsWriter) AddKey(key string)

AddKey adds the key for a new object field. A comma is prefixed if another field has previously been added.

func (*JSONFieldsWriter) BoolField

func (w *JSONFieldsWriter) BoolField(key string, val bool)

BoolField adds a bool field to the object.

func (*JSONFieldsWriter) FloatField

func (w *JSONFieldsWriter) FloatField(key string, val float64)

FloatField adds a float field to the object.

func (*JSONFieldsWriter) IntField

func (w *JSONFieldsWriter) IntField(key string, val int64)

IntField adds an int field to the object.

func (*JSONFieldsWriter) NoComma added in v0.5.0

func (w *JSONFieldsWriter) NoComma()

NoComma ensures that a comma won't be added before the next field this JsonFieldsWriter writes.

func (*JSONFieldsWriter) RawField

func (w *JSONFieldsWriter) RawField(key string, val json.RawMessage)

RawField adds a raw JSON field to the object.

func (*JSONFieldsWriter) StringField

func (w *JSONFieldsWriter) StringField(key string, val string)

StringField adds a string field to the object.

func (*JSONFieldsWriter) WriterField

func (w *JSONFieldsWriter) WriterField(key string, val JSONWriter)

WriterField adds a JSONWriter field to the object.

type JSONWriter

type JSONWriter interface {
	WriteJSON(buf *bytes.Buffer)
}

JSONWriter is something that can write JSON to a buffer.

type OrderedAttributes

type OrderedAttributes map[string]interface{}

OrderedAttributes turns attributes into JSON in a fixed order.

func (OrderedAttributes) WriteJSON

func (attrs OrderedAttributes) WriteJSON(buf *bytes.Buffer)

WriteJSON writes the attributes in JSON in a fixed order.

Directories

Path Synopsis
Package jsonx extends the encoding/json package to encode JSON incrementally and without requiring reflection.
Package jsonx extends the encoding/json package to encode JSON incrementally and without requiring reflection.

Jump to

Keyboard shortcuts

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