json

package
v0.0.0-...-203dfb9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package json manages applying a program of selectors, processors, and extractors as defined by the jq program against input JSON and producing the result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Processor

type Processor interface {
	Process(source io.Reader, program string) (io.Reader, error)
}

Processor runs a set of commands over some input JSON and outputs the result

type Shell

type Shell struct {
	Debug io.Writer
	// contains filtered or unexported fields
}

Shell makes calls to the jq binary installed in the current environment to implement the Processor interface.

func NewShell

func NewShell(opts ...ShellOption) (*Shell, error)

NewShell returns a new shell Processor with all configurations applied.

func (*Shell) Process

func (sh *Shell) Process(source io.Reader, program string) (io.Reader, error)

Process runs the input JSON and the processing program through the jq command with both as inputs via stdin. The results or a possible error are returned.

func (*Shell) ToggleCompact

func (sh *Shell) ToggleCompact()

ToggleCompact flips the internal compact option

func (*Shell) ToggleRaw

func (sh *Shell) ToggleRaw()

ToggleRaw flips the internal raw option

type ShellOption

type ShellOption func(*Shell) (*Shell, error)

ShellOption allows a client to configure the behavior of the underlying jq process

func OptionCompact

func OptionCompact(compact bool) ShellOption

OptionCompact tells jq to return compact output

func OptionRaw

func OptionRaw(raw bool) ShellOption

OptionRaw tells jq to return compact output

Jump to

Keyboard shortcuts

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