input

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format int

Format describes the JSON format of input data.

const (
	FormatAuto Format = iota
	FormatJSON
	FormatJSONL
)

func DetectFormat

func DetectFormat(peek []byte) Format

DetectFormat examines the first non-whitespace bytes to determine the format. [ -> FormatJSON (array), single {...} -> FormatJSON, multiple {...}\n{...} -> FormatJSONL.

type Object

type Object struct {
	Value any    // the parsed JSON value
	File  string // source filename ("stdin" for stdin)
	Index int    // 0-based index within the file
}

Object represents one JSON object with its source metadata.

type Reader

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

Reader streams JSON objects from files or stdin.

func NewReader

func NewReader(files []string, opts ReaderOpts) (*Reader, error)

NewReader creates a reader that will stream objects from the given files. Use "-" to read from stdin.

func (*Reader) Next

func (r *Reader) Next() (*Object, error)

Next returns the next Object or (nil, nil) at EOF.

type ReaderOpts

type ReaderOpts struct {
	Format    Format
	Strict    bool // error on malformed lines
	Silent    bool // suppress warnings
	MaxErrors int  // abort after N errors (0 = unlimited)
}

ReaderOpts configures the streaming reader.

Jump to

Keyboard shortcuts

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