jsonarray

package
v1.0.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package jsonarray provides JSON-array import and export for the pulse I/O pipeline. The format is a single top-level JSON array of flat objects: [{...}, {...}].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader reads a top-level JSON array of objects, one object per row.

func NewReader

func NewReader(fs afero.Fs, path string) *Reader

NewReader creates a Reader from a filesystem path.

func NewReaderFromBytes

func NewReaderFromBytes(data []byte) *Reader

NewReaderFromBytes creates a Reader from raw bytes.

func (*Reader) Close

func (r *Reader) Close() error

Close releases resources.

func (*Reader) ReadHeader

func (r *Reader) ReadHeader() ([]string, error)

ReadHeader returns column names from the first JSON object.

func (*Reader) ReadRows

func (r *Reader) ReadRows(ctx context.Context, fn func(row []string) error) error

ReadRows streams rows to fn. ReadHeader is auto-called if not yet invoked.

func (*Reader) RefuseLateKeys

func (r *Reader) RefuseLateKeys(on bool)

RefuseLateKeys implements iocore.LateKeyRefuser: when on, a key first seen after the first object fails ReadRows with PULSE_IMPORT_SCHEMA_KEY_LATE instead of being dropped. Survives Reset.

func (*Reader) Reset

func (r *Reader) Reset() error

Reset rewinds the reader to the beginning.

func (*Reader) RowList

func (r *Reader) RowList(col int, dst *iocore.ListCell) error

RowList implements iocore.ListAwareReader: the current object's value under header column col read as a typed numeric list (jsonshared.ListCellOf).

func (*Reader) RowNulls

func (r *Reader) RowNulls() []bool

RowNulls implements iocore.NullAwareReader. Entry i is true when the current row's column i was JSON null, or absent from the object.

type Writer

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

Writer writes a JSON array, one object per row.

func NewWriter

func NewWriter(fs afero.Fs, path string) *Writer

NewWriter creates a Writer targeting a filesystem path.

func NewWriterToBuffer

func NewWriterToBuffer() *Writer

NewWriterToBuffer creates a Writer that accumulates output in an internal buffer.

func (*Writer) Bytes

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

Bytes returns the buffered JSON output. Callers should call Close first.

func (*Writer) Close

func (w *Writer) Close() error

Close emits the closing ']' and flushes to the target path if configured.

func (*Writer) SetExplicitNulls

func (w *Writer) SetExplicitNulls(on bool)

SetExplicitNulls implements iocore.NullAwareWriter.

func (*Writer) SetListColumns

func (w *Writer) SetListColumns(cols []iocore.ListColumn)

SetListColumns implements iocore.ListAwareWriter; see the ndjson Writer's method of the same name.

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(columns []string) error

WriteHeader stores the column names and emits the opening '['.

func (*Writer) WriteRow

func (w *Writer) WriteRow(values []any) error

WriteRow writes a single object element.

Jump to

Keyboard shortcuts

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