json

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package json reads JSON values into documents.

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 parses a JSON payload into *document.Document entries. Top-level arrays produce one document per element; every other JSON value produces one document containing its raw representation. Numbers retain their source spelling and are not restricted to the float64 range.

Use it to ingest API responses, dump files, or seed fixture data.

Example:

r, err := json.NewReader(strings.NewReader(`[{"id":1},{"id":2}]`), json.ReaderConfig{})
docs, err := r.Read(ctx) // 2 documents

func NewReader

func NewReader(source io.Reader, config ReaderConfig) (*Reader, error)

NewReader validates the typed JSON projection and source budget before any input is consumed.

func (*Reader) Read

func (r *Reader) Read(ctx context.Context) ([]*document.Document, error)

Read consumes the source and converts its top-level value to documents.

type ReaderConfig

type ReaderConfig struct {
	SourceBudget etl.SourceBudget
}

ReaderConfig controls the whole-source memory budget. The zero budget uses etl.DefaultMaxSourceBytes.

Jump to

Keyboard shortcuts

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