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 ¶
- func Marshal(w *Writer, v interface{})
- type Appender
- type Marshaler
- type Writer
- func (w *Writer) Bool(v bool)
- func (w *Writer) Bytes() []byte
- func (w *Writer) Float32(n float32)
- func (w *Writer) Float64(n float64)
- func (w *Writer) Int64(n int64)
- func (w *Writer) RawByte(c byte)
- func (w *Writer) RawBytes(data []byte)
- func (w *Writer) RawString(s string)
- func (w *Writer) Reset()
- func (w *Writer) Rewind(size int)
- func (w *Writer) Size() int
- func (w *Writer) String(s string)
- func (w *Writer) StringContents(s string)
- func (w *Writer) Time(t time.Time, layout string)
- func (w *Writer) Uint64(n uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) Bytes ¶
Bytes returns the internal buffer. The result is invalidated when Reset is called.
func (*Writer) Rewind ¶
Rewind rewinds the buffer such that it has size bytes, dropping everything proceeding.
func (*Writer) StringContents ¶
StringContents is the same as String, but without the surrounding quotes.