json

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package json 提供从 JSON 文件读取数据的 Source

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// FilePath JSON 文件路径,支持 glob 模式
	FilePath string `json:"file_path"`
	// Format 格式: "lines" (JSON Lines) 或 "array" (JSON 数组),默认 "lines"
	Format string `json:"format"`
	// BatchSize 每次读取的批次大小,0 表示无限制
	BatchSize int `json:"batch_size"`
}

Config Source 的配置

type SliceSource

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

SliceSource 从内存中的 JSON 数据读取,用于测试

func NewSliceSource

func NewSliceSource() *SliceSource

NewSliceSource 创建新的 SliceSource

func (*SliceSource) Init

func (s *SliceSource) Init(config []byte) error

Init 初始化 Source

func (*SliceSource) Read

func (s *SliceSource) Read(ctx context.Context, out chan<- types.Record) (int64, error)

Read 将内存中的 JSON 数据写入输出通道

type Source

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

Source 从 JSON 文件读取数据,支持 JSON Lines 和 JSON 数组格式

func New

func New() *Source

New 创建新的 Source

func (*Source) Init

func (s *Source) Init(config []byte) error

Init 初始化 Source

func (*Source) Read

func (s *Source) Read(ctx context.Context, out chan<- types.Record) (int64, error)

Read 从 JSON 文件读取数据

Jump to

Keyboard shortcuts

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