jsonfilter

package
v2.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *logger.Logger

Functions

func IsScalarArray added in v2.57.0

func IsScalarArray(node gjson.Result) bool

IsScalarArray returns true if the array only contains scalar values

func MergeKeyGroups added in v2.55.0

func MergeKeyGroups(rows [][]KeyGroup) []string

MergeKeyGroups merges the resolved keys of multiple sampled rows into a single ordered column list. Columns are ordered by select pattern, and each pattern expands to the union of the keys it resolved to across all rows (deduplicated case insensitively). Patterns which did not resolve against any row are included as-is so the user can still see which selector returned nothing

Types

type HeaderFunc added in v2.55.0

type HeaderFunc func(keys string, groups []KeyGroup)

HeaderFunc callback which receives the resolved keys of a single row. keys is the flat comma separated list (unmatched patterns are included as-is), and groups contains the keys grouped by the select pattern which resolved them

type JSONFilter

type JSONFilter struct {
	Property  string
	Operation string
	Value     interface{}
}

type JSONFilters

type JSONFilters struct {
	Logger             *logger.Logger
	Filters            []JSONFilter
	Pluck              []string
	Flatten            bool
	AsCSV              bool
	AsTSV              bool
	AsCompletionFormat bool

	// SkipHeaders indicates that the output format does not consume the
	// per-row header callback (e.g. json output), allowing rows that select
	// every property (globstar) to be passed through without being
	// flattened just to resolve header names.
	SkipHeaders bool
}

func NewJSONFilters

func NewJSONFilters(l *logger.Logger) *JSONFilters

NewJSONFilters create a json filter

func (*JSONFilters) Add

func (f *JSONFilters) Add(property, operation string, value interface{})

func (*JSONFilters) AddRawFilters

func (f *JSONFilters) AddRawFilters(rawFilters []string) error

AddRawFilters add list of raw filters

func (JSONFilters) Apply

func (f JSONFilters) Apply(jsonValue string, property string, showHeaders bool, setHeaderFunc HeaderFunc) ([]byte, error)

type KeyGroup added in v2.55.0

type KeyGroup = shape.KeyGroup

KeyGroup records which concrete json keys a single select pattern resolved to within one row. Keys is empty when the pattern did not match anything in the row

func CollapseScalarArrays added in v2.57.0

func CollapseScalarArrays(groups []KeyGroup, doc string) []KeyGroup

CollapseScalarArrays replaces the per-index keys of arrays which only contain scalar values (string, number, boolean, null), e.g. tags.0, tags.1, with a single key for the array itself (tags), so the array is rendered as one table column. Keys which the user selected explicitly (e.g. tags.0) and arrays containing objects or arrays are left untouched.

Jump to

Keyboard shortcuts

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