jwriter

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jwriter contains a JSON writer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufWriter

type BufWriter struct {
	Buffer       buffer.Buffer
	NoEscapeHTML bool
	// contains filtered or unexported fields
}

Writer is a JSON writer.

func (*BufWriter) Base64Bytes

func (w *BufWriter) Base64Bytes(data []byte) error

Base64Bytes appends data to the buffer after base64 encoding it

func (*BufWriter) Bool

func (w *BufWriter) Bool(v bool) error

func (*BufWriter) BuildBytes

func (w *BufWriter) BuildBytes(reuse ...[]byte) ([]byte, error)

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 (*BufWriter) Close added in v0.8.4

func (w *BufWriter) Close() error

func (*BufWriter) DumpTo

func (w *BufWriter) DumpTo(out io.Writer) (written int, err error)

DumpTo outputs the data to given io.Writer, resetting the buffer.

func (*BufWriter) Flags

func (w *BufWriter) Flags() Flags

Size returns the size of the data that was written out.

func (*BufWriter) Float32

func (w *BufWriter) Float32(n float32) error

func (*BufWriter) Float32Str

func (w *BufWriter) Float32Str(n float32) error

func (*BufWriter) Float64

func (w *BufWriter) Float64(n float64) error

func (*BufWriter) Float64Str

func (w *BufWriter) Float64Str(n float64) error

func (*BufWriter) Flush

func (w *BufWriter) Flush() error

func (*BufWriter) Int

func (w *BufWriter) Int(n int) error

func (*BufWriter) Int8

func (w *BufWriter) Int8(n int8) error

func (*BufWriter) Int8Str

func (w *BufWriter) Int8Str(n int8) error

func (*BufWriter) Int16

func (w *BufWriter) Int16(n int16) error

func (*BufWriter) Int16Str

func (w *BufWriter) Int16Str(n int16) error

func (*BufWriter) Int32

func (w *BufWriter) Int32(n int32) error

func (*BufWriter) Int32Str

func (w *BufWriter) Int32Str(n int32) error

func (*BufWriter) Int64

func (w *BufWriter) Int64(n int64) error

func (*BufWriter) Int64Str

func (w *BufWriter) Int64Str(n int64) error

func (*BufWriter) IntStr

func (w *BufWriter) IntStr(n int) error

func (*BufWriter) RawByte

func (w *BufWriter) RawByte(c byte) error

RawByte appends raw binary data to the buffer.

func (*BufWriter) RawBytes

func (w *BufWriter) RawBytes(data []byte) error

RawByte appends raw binary data to the buffer.

func (*BufWriter) RawBytesWithErr

func (w *BufWriter) RawBytesWithErr(data []byte, err error) error

func (*BufWriter) RawString

func (w *BufWriter) RawString(s string) error

RawByte appends raw binary data to the buffer.

func (*BufWriter) RawTextWithErr

func (w *BufWriter) RawTextWithErr(data []byte, err error) error

func (*BufWriter) SetFlags

func (w *BufWriter) SetFlags(f Flags)

Size returns the size of the data that was written out.

func (*BufWriter) Size

func (w *BufWriter) Size() int

Size returns the size of the data that was written out.

func (*BufWriter) String

func (w *BufWriter) String(s string) error

func (*BufWriter) Uint

func (w *BufWriter) Uint(n uint) error

func (*BufWriter) Uint8

func (w *BufWriter) Uint8(n uint8) error

func (*BufWriter) Uint8Str

func (w *BufWriter) Uint8Str(n uint8) error

func (*BufWriter) Uint16

func (w *BufWriter) Uint16(n uint16) error

func (*BufWriter) Uint16Str

func (w *BufWriter) Uint16Str(n uint16) error

func (*BufWriter) Uint32

func (w *BufWriter) Uint32(n uint32) error

func (*BufWriter) Uint32Str

func (w *BufWriter) Uint32Str(n uint32) error

func (*BufWriter) Uint64

func (w *BufWriter) Uint64(n uint64) error

func (*BufWriter) Uint64Str

func (w *BufWriter) Uint64Str(n uint64) error

func (*BufWriter) UintStr

func (w *BufWriter) UintStr(n uint) error

func (*BufWriter) UintptrStr

func (w *BufWriter) UintptrStr(n uintptr) error

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.

const (
	NilMapAsEmpty   Flags = 1 << iota // Encode nil map as '{}' rather than 'null'.
	NilSliceAsEmpty                   // Encode nil slice as '[]' rather than 'null'.
)

type Writer

type Writer interface {
	Flags() Flags

	Flush() error

	// Close resets the buffer.
	Close() error

	// RawByte appends raw binary data to the buffer.
	RawByte(c byte) error

	// RawByte appends raw binary data to the buffer.
	RawBytes(data []byte) error

	RawBytesWithErr(data []byte, err error) error

	RawTextWithErr(data []byte, err error) error

	// RawByte appends raw binary data to the buffer.
	RawString(s string) error

	// Base64Bytes appends data to the buffer after base64 encoding it
	Base64Bytes(data []byte) error

	Uint8(n uint8) error

	Uint16(n uint16) error

	Uint32(n uint32) error

	Uint(n uint) error

	Uint64(n uint64) error

	Int8(n int8) error

	Int16(n int16) error

	Int32(n int32) error

	Int(n int) error

	Int64(n int64) error

	Uint8Str(n uint8) error

	Uint16Str(n uint16) error

	Uint32Str(n uint32) error

	UintStr(n uint) error

	Uint64Str(n uint64) error

	UintptrStr(n uintptr) error

	Int8Str(n int8) error

	Int16Str(n int16) error

	Int32Str(n int32) error

	IntStr(n int) error

	Int64Str(n int64) error

	Float32(n float32) error

	Float32Str(n float32) error

	Float64(n float64) error

	Float64Str(n float64) error

	Bool(v bool) error

	String(s string) error
}

func NewStreamingTokenWriter

func NewStreamingTokenWriter(dest io.Writer, bufferSize int) Writer

Jump to

Keyboard shortcuts

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