jsonarray

package
v0.0.0-...-2fd0e60 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MPL-2.0 Imports: 6 Imported by: 1

README

jsonarray

Streaming for JSON Arrays

Documentation

Overview

Package jsonarray provides an interface to stream an array of JSON objects to an io.Writer. This is useful for streaming long JSON arrays to an HTTP response.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder[T any] struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder[T any](w io.Writer, hotPipe bool) *Encoder[T]

func (*Encoder[T]) Encode

func (ae *Encoder[T]) Encode(v T) error

Encode writes a JSON object to the underlying io.Writer. If the ArrayEncoder was created with hotPipe set to true, it will also flush the writer after writing the object. It is assumed that writing is being done in a single goroutine. If there's a chance of concurrent writes, lock the function invocation with a mutex.

func (*Encoder[T]) Finish

func (ae *Encoder[T]) Finish() error

func (*Encoder[T]) Reset

func (ae *Encoder[T]) Reset()

func (*Encoder[T]) SetIndent

func (ae *Encoder[T]) SetIndent(prefix, indent string)

Jump to

Keyboard shortcuts

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