jsonl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package jsonl implements source.Source over JSON Lines: one JSON object per line. Each line becomes a Record whose Data is the original bytes and whose Fields is the decoded object, tagged domain.KindJSON. Numbers are decoded as json.Number so large integer IDs keep their exact value instead of rounding through float64. Blank lines are skipped; a non-blank line that is not a single JSON object is a clear error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

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

Source yields one Record per JSON object in the underlying reader.

func New

func New(r io.Reader, name string) *Source

New returns a Source reading JSON Lines from r. name labels the stream in record IDs (e.g. "stdin", a file path). If r is an io.Closer it is closed by Close.

func Open

func Open(path string) (*Source, error)

Open returns a Source reading JSON Lines from the file at path.

func (*Source) Close

func (s *Source) Close() error

Close implements source.Source. Safe to call more than once, and concurrently with Next: closing the reader unblocks a pending read so a cancelled run can stop instead of hanging on stdin or a pipe.

func (*Source) Next

func (s *Source) Next(ctx context.Context) (domain.Record, error)

Next implements source.Source. Line numbers are 1-based and count blank lines, so they line up with the file even though blanks are skipped.

Jump to

Keyboard shortcuts

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