Documentation ¶
Overview ¶
Package jwriter contains a JSON writer.
Index ¶
- func Put(b *Writer)
- type Flags
- type Pool
- type Writer
- func (w *Writer) Base64Bytes(data []byte)
- func (w *Writer) Bool(v bool)
- func (w *Writer) BuildBytes(reuse ...[]byte) ([]byte, error)
- func (w *Writer) DumpTo(out io.Writer) (written int, err error)
- func (w *Writer) Float32(n float32)
- func (w *Writer) Float32Str(n float32)
- func (w *Writer) Float64(n float64)
- func (w *Writer) Float64Str(n float64)
- func (w *Writer) Int(n int)
- func (w *Writer) Int16(n int16)
- func (w *Writer) Int16Str(n int16)
- func (w *Writer) Int32(n int32)
- func (w *Writer) Int32Str(n int32)
- func (w *Writer) Int64(n int64)
- func (w *Writer) Int64Str(n int64)
- func (w *Writer) Int8(n int8)
- func (w *Writer) Int8Str(n int8)
- func (w *Writer) IntStr(n int)
- func (w *Writer) Raw(data []byte, err error)
- func (w *Writer) RawByte(c byte)
- func (w *Writer) RawString(s string)
- func (w *Writer) RawText(data []byte, err error)
- func (w *Writer) ReadCloser() (io.ReadCloser, error)
- func (w *Writer) Reset()
- func (w *Writer) Size() int
- func (w *Writer) String(s string)
- func (w *Writer) Uint(n uint)
- func (w *Writer) Uint16(n uint16)
- func (w *Writer) Uint16Str(n uint16)
- func (w *Writer) Uint32(n uint32)
- func (w *Writer) Uint32Str(n uint32)
- func (w *Writer) Uint64(n uint64)
- func (w *Writer) Uint64Str(n uint64)
- func (w *Writer) Uint8(n uint8)
- func (w *Writer) Uint8Str(n uint8)
- func (w *Writer) UintStr(n uint)
- func (w *Writer) UintptrStr(n uintptr)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Flags ¶
type Flags int
Flags describe various encoding options. The behavior may be actually implemented in the encoder, but Flags field in Writer is used to set and pass them around.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool represents byte buffer pool.
Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.
type Writer ¶
Writer is a JSON writer.
func Get ¶
func Get() *Writer
Get returns an empty byte buffer from the pool.
Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.
func (*Writer) Base64Bytes ¶
Base64Bytes appends data to the buffer after base64 encoding it
func (*Writer) BuildBytes ¶
BuildBytes returns writer data as a single byte slice. You can optionally provide one byte slice as argument that it will try to reuse.
func (*Writer) Float32Str ¶
func (*Writer) Float64Str ¶
func (*Writer) Raw ¶
Raw appends raw binary data to the buffer or sets the error if it is given. Useful for calling with results of MarshalJSON-like functions.
func (*Writer) RawText ¶
RawText encloses raw binary data in quotes and appends in to the buffer. Useful for calling with results of MarshalText-like functions.
func (*Writer) ReadCloser ¶
func (w *Writer) ReadCloser() (io.ReadCloser, error)
ReadCloser returns an io.ReadCloser that can be used to read the data. ReadCloser also resets the buffer.