jsoncodec

package
v0.0.0-...-8a86631 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jsoncodec provides a JSON implementation of the Codec interface, allowing tabular data to be exported in either standard JSON array format or newline-delimited JSON (JSON Lines). It supports per-type value mapping, row preprocessing, and row limits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) *jsonCodec

New creates a new JSON codec with the provided configuration options.

Types

type Option

type Option func(*jsonCodec)

Option defines a functional configuration option for jsonCodec.

func WithCustomType

func WithCustomType[T any](fn func(v T, metadata scanner.Metadata) any) Option

WithCustomType registers a custom mapping function to convert a specific Go type to its JSON representation, using optional metadata.

func WithLimit

func WithLimit(limit int) Option

WithLimit sets a limit on the number of rows to export. A negative value disables the limit.

func WithNewlineDelimited

func WithNewlineDelimited(isNewlineDelimited bool) Option

WithNewlineDelimited enables newline-delimited JSON (JSON Lines) format.

func WithPreProcessorFunc

func WithPreProcessorFunc(fn func(rowID int, row map[string]any) (map[string]any, bool)) Option

WithPreProcessorFunc sets a function to transform or filter each row before writing. The function can modify the row contents or skip the row entirely.

Jump to

Keyboard shortcuts

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