fastjson

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fastjson provides a code generator and library for fast JSON encoding, limited to what apm-agent-go requires.

fastjson reuses a small amount of easyjson's code for marshalling strings. Whereas easyjson relies on pooled memory, fastjson leaves memory allocation to the user. For apm-agent-go, we always encode from a single goroutine, so we can reuse a single buffer, and so we can almost always avoid allocations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(w *Writer, v interface{})

Marshal marshals v as JSON to w.

Types

type Appender

type Appender interface {
	// AppendJSON appends the JSON representation of the value to the
	// buffer, and returns the extended buffer.
	AppendJSON([]byte) []byte
}

Appender defines an interface that types can implement to append their JSON representation to a buffer. If the value is not a valid JSON token, it will be rejected.

type Marshaler

type Marshaler interface {
	// MarshalFastJSON writes a JSON representation of the type to w.
	MarshalFastJSON(w *Writer)
}

Marshaler defines an interface that types can implement to provide fast JSON marshaling.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a JSON writer.

func (*Writer) Bool

func (w *Writer) Bool(v bool)

Bool appends v to the buffer.

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes returns the internal buffer. The result is invalidated when Reset is called.

func (*Writer) Float32

func (w *Writer) Float32(n float32)

Float32 appends n to the buffer.

func (*Writer) Float64

func (w *Writer) Float64(n float64)

Float64 appends n to the buffer.

func (*Writer) Int64

func (w *Writer) Int64(n int64)

Int64 appends n to the buffer.

func (*Writer) RawByte

func (w *Writer) RawByte(c byte)

RawByte appends c to the buffer.

func (*Writer) RawBytes

func (w *Writer) RawBytes(data []byte)

RawBytes appends data, unmodified, to the buffer.

func (*Writer) RawString

func (w *Writer) RawString(s string)

RawString appends s to the buffer.

func (*Writer) Reset

func (w *Writer) Reset()

Reset resets the internal []byte buffer to empty.

func (*Writer) Rewind

func (w *Writer) Rewind(size int)

Rewind rewinds the buffer such that it has size bytes, dropping everything proceeding.

func (*Writer) Size

func (w *Writer) Size() int

Size returns the current size of the buffer.

func (*Writer) String

func (w *Writer) String(s string)

String appends s, quoted and escaped, to the buffer.

func (*Writer) StringContents

func (w *Writer) StringContents(s string)

StringContents is the same as String, but without the surrounding quotes.

func (*Writer) Time

func (w *Writer) Time(t time.Time, layout string)

Time appends t to the buffer, formatted according to layout.

func (*Writer) Uint64

func (w *Writer) Uint64(n uint64)

Uint64 appends n to the buffer.

Jump to

Keyboard shortcuts

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